MessagingEventStream (MES) is used inside a BizTalk pipeline component to write Bam as part of the messaging transactions ensuring that your BAM event persistence remains in sync with the BizTalk pipeline transactions.
Messaging Event Streams are asynchronous and store 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). This class is derived from the base class EventStream.
MES is available since BizTalk 2004 with SP1.
Normally, we write the code to produce BAM events in the Execute method of the pipeline component. Execute method have two parameters:
- An IPipelineContext: contains the pipeline context
- An IBaseMessage: contains the message being processed.
The pipeline context has a GetEventStream method that returns a MessagingEventStream.
Code sample
public IBaseMessage Execute(IPipelineContext context, IBaseMessage message) { //Get the Messaging Event Stream MessagingEventStream eventStream = context.GetEventStream(); … //Write to BAM //Create a new, unique activity identifier to use as the ActivityID in BAM string activityId = Guid.NewGuid().ToString() + "_" + DateTime.Now; //Start the activity record identified by activityId eventStream.BeginActivity("MyTrackingDemo", activityId); // Updates the activity record. eventStream.UpdateActivity("MyTrackingDemo", activityId, "MESSAGE_ID", message.MessageID, "TRANSACTION_CREATED", DateTime.UtcNow); eventStream.EndActivity("MyTrackingDemo", activityId); // Optional Flush eventStream.Flush(); }
Found what I was looking for.
Found what I was looking for. There is only one problem with this code.A could not find reference for MessageEventStream. Instead i used var type. Worked fine for me,