Using the BAM API to write BAM events from orchestrations

One of the easiest ways to update a bam activity from an orchestration is to use the BAM API, Simply add reference to

  • Microsoft.BizTalk.Bam.EventObservartion
  • Microsoft.BizTalk.Bam.XLANGs
to your project and you are ready to start.
In the basic level you have to start, update and end an activity.

Start Activity

I reccomend creating variables for activity name and instanceID, To avoid any confutions. The Activity name must match the Activity name created and deployed using bm.exe. (I will create a seperate post for this)

The code in start-bam-expression-shape in orchestration PreProcessInvoice will then look something like this:

activityName = ("ProcessInvoice");//this is the activity we are loading data into
activityInstance = System.Convert.ToString(System.Guid.NewGuid())+"PreProcessInvoice"; //if bamming to same activity from different orchestration, we may track where the data is comming from by adding orchestration name.


Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.BeginActivity(activityName, activityInstance);


Update Activity

Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.UpdateActivity(activityName, activityInstance,
    "PurchadeOrderNumber", poNumber,
    "InvoiceDate", date,
    "Company", company );
When updating an activity, the object we are adding is in fact a key-value pair, where the Key needs to match the databasefield name, and value needs to be compliant with the database datatype. More ond advanced stuff in a seperate post. For now we will stick to using text.

End Activity

Nothing special about this at all.
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.EndActivity (activityName, activityInstance);

Comments

Popular posts from this blog

Illegal 'activate' predecate

BizTalk Host "Stop Pending"

The Messaging Engine failed to register an adapter "WCF-BasicHttp". Details: "Registering multiple adapter types within the same process is not a supported configuration. For e.g. HTTP and SOAP receive adapters cannot co-exist in the same process