locked
Biztak BAM Events Updating through Pipleine RRS feed

  • Question

  • Hi,

    I have a requirement where i have to read my schema fields and Update it to BAM.

    In Orchestration,Since the schema will be in XLANG Message i can pass it to a Helper Class which uses BAMAPI'S and Update it to BAM.

    But in Pipeline,since the Message will be in IBASEmessage and its a stream I am not sure how can we read the fields in schema in a Pipeline?

    Can you help me with this?

    Thanks,

    Sujith.

    Friday, April 22, 2016 6:32 PM

Answers

  • Hi Sujith,

    If you wish to update BAM in pipeline you should be suing BAM MessagingEventStream

    Refer: BAM API – Using MessagingEventStream to write BAM Events from pipeline components

    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.

    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.

    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();
    }

    Secondly, If you wish to update BAM through an orchestration, you should be using the BAM OrchestrationEventStream.

    OrchestrationEventStream used to programmatically populate a BAM activity model from within a BizTalk orchestration. 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).

    AddRefernce: Adds a reference to an item that relates to the current activity instance.

    BeginActivity: Creates a new activity record if data is tracked using the UpdateActivity method.

    UPdateActivity: Updates the activity record.

    EndActivity: Indicates that there are no more events expected for the given activity instance or continuation token.

    These method are used to insert/update data into BAM activitties https://www.microsoft.com/biztalk/en/us/business-activity-monitoring.aspx.  

    Read this white paper from MSDN for more info: Business Activity Monitoring in Depth for Developers

    Reference:

    http://sandroaspbiztalkblog.wordpress.com/2010/08/23/bam-api-%E2%80%93-using-orchestrationeventstream-to-write-bam-events-from-biztalk-orchestration/

    EventStream Methods

    http://blogs.biztalk360.com/bam-production-environment-management/


    Rachit Sikroria (Microsoft Azure MVP)

    Friday, April 22, 2016 6:46 PM
    Moderator

All replies

  • Hi Sujith,

    If you wish to update BAM in pipeline you should be suing BAM MessagingEventStream

    Refer: BAM API – Using MessagingEventStream to write BAM Events from pipeline components

    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.

    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.

    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();
    }

    Secondly, If you wish to update BAM through an orchestration, you should be using the BAM OrchestrationEventStream.

    OrchestrationEventStream used to programmatically populate a BAM activity model from within a BizTalk orchestration. 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).

    AddRefernce: Adds a reference to an item that relates to the current activity instance.

    BeginActivity: Creates a new activity record if data is tracked using the UpdateActivity method.

    UPdateActivity: Updates the activity record.

    EndActivity: Indicates that there are no more events expected for the given activity instance or continuation token.

    These method are used to insert/update data into BAM activitties https://www.microsoft.com/biztalk/en/us/business-activity-monitoring.aspx.  

    Read this white paper from MSDN for more info: Business Activity Monitoring in Depth for Developers

    Reference:

    http://sandroaspbiztalkblog.wordpress.com/2010/08/23/bam-api-%E2%80%93-using-orchestrationeventstream-to-write-bam-events-from-biztalk-orchestration/

    EventStream Methods

    http://blogs.biztalk360.com/bam-production-environment-management/


    Rachit Sikroria (Microsoft Azure MVP)

    Friday, April 22, 2016 6:46 PM
    Moderator
  • Hi Sujith

    In addition to what Rachit said, there is a elegant/no-code way of getting data from pipelines to BAM activities.

    This approach makes use of the Tracking Profile Editor to map the fields in an activity with the message/context data flowing through a BizTalk port. You need to create the activity definition prior to creating this mapping via the TPE.

    Once this configuration is applied, message that comes in via the above port would automatically flow into the BAM activity tables.

    Ref:

    See section 4 here for this approach-

    http://www.codeproject.com/Articles/868640/BizTalks-Business-Activity-Monitoring-BAM

    https://msdn.microsoft.com/en-us/library/aa560474.aspx


    Thanks Arindam

    Saturday, April 23, 2016 1:54 AM
    Moderator
  • There are two API one the OrchestrationEventStream which should be used through Orchestrations and the MessagingEventStream should be used from within the Pipeline Components.

    MessagingEventStream is preferred for Messaging Only scenarios as it is a direct write as opposed to the more reliable buffered OrchestrationEventStream.

    In your case you have an orchestration so a simpler mechanism for you would be to create a PropertySchema through which you can promote pipeline related data elements into the Message Context and use the Orchestration event stream to capture it into BAM.

    However, if you intend to use a combination of the Messaging and Orchestration Event streams in your solution then you should also pay attention to the correct use of Continuation Id/Token. IMHO https://msdn.microsoft.com/en-us/library/dd320628(v=bts.10).aspx - Business Activity Monitoring in Depth for Developers is an excellent resource to help you get around the nuances of BAM.

    Regards.

    Saturday, April 23, 2016 7:06 AM