In BizTalk, BAM applies on pipeline level and in orchestration. Here we are going to implement BAM in Orchestration through BAM API programming.
For more details of BAM APIs, you can refer to
Normally for BAM Programming below three functions are required under EventStream class.
If you want some more advance feature in BAM tracking then you can refer below reference:
Add below Dlls in BizTalk project references:
Write below code in orchestration expression shapes:
//Create a new, unique activity identifier to use as the ActivityID in BAM
string activityId = Guid.NewGuid().ToString();
// Updates the activity record.
Microsoft.BizTalk.Bam.EventObservation.OrchestrationEventStream.UpdateActivity ActivityName, activityID, “FIleName”, msg(BTS.FileName), “ProcessStart”, DateTime.UtcNow,);
// End the activity record.
Here you can use different expression shape for above methods, Be sure EndActivity method should be in last of orchestration. And StartActivity methad in starting of Orchestration.
Below is explanation of data and function which are used in orchestration expression shapes:
ActivityName: BAM Definition File Name
ActivityID: It can be a GUID or any unique id
public virtual void UpdateActivity( string activityName, string ctivityInstance, params object data)
In Update activity, after first two parameters, data items are next parameters which are defined in key value pairs.
These data items can be defined in single UpdateActivity function as well as in separate activity function. E.g. In below BAM table, there are following data items.
Data1, data2, starttime, endtime, errordetails, status, lastmodified.
Here we can write update function as per requirements, it’s not mandatory to define all data items in one time.
UpdateActivity(“BAMSample”, ActivityID, “starttime”, DateTime.Now);
UpdateActivity(“BAMSample”, ActivityID, “Status”, “OperationStart”);
You can track info on BAM Portal or BAM definition table in BAM Primary Import Database.
When you defining BAM Definition file then BAM creates five table in BAMPrimaryImport table.
You can check data in Bam_<BAM Definition File>_Completed table.
How does EventStream work in Orchestration?
The OES API stores tracking data first in the BizTalk MessageBox database. Periodically the data is processed and persisted to the BAM Primary Import database by the Tracking Data Decode Service (TDDS).
The OES API is found in the Microsoft.BizTalk.Bam.EventObservation namespace.
2 responses to “BAM in Orchestration”
[…] Apply BAM in Orchestration: https://vkbiztalk.wordpress.com/2017/07/27/bam-in-orchestration/ […]
Simple and well explained. Tried it first time and data logged into the tables. Expecting some more articles on BAM.