Tuesday 12 July 2016

BAM Tracking End to End in BizTalk


This article will show how to implement E2E BAM Tracking by enabling Continuation between Receive, Orchestration and Send Ports.

BAM
Information workers need flexibility in looking at and evaluating business processes. A purchasing manager might need to see how many POs are approved and denied each day, for example, while a sales manager might want an hourly update on what products are being ordered. Meeting these diverse needs requires a general framework for tracking what’s going on with a particular business process. This is exactly what the Business Activity Monitoring (BAM) component in Microsoft BizTalk Server provides

BAM is used to monitor business milestones and key metrics in near real-time throughout a process in BizTalk. BAM is tied directly to the central BizTalk engine (that is, processes and databases) through OLAP cubes. These cubes are created automatically when a developer deploys a BAM report and profile, typically by using a combination of Microsoft Excel pivot tables and the BizTalk Tracking Profile Editor.

BAM Activities 
BAM activities identify the milestones and tracking data an individual is interested in tracking. Milestones are the steps in an activity that are measured in time, and tracking data is the key data points in a process you are interested in tracking (such as a customer ID or name).

BAM View
A BAM view is a representation of the milestones and business data tracked in one or more activities.

The Group milestone allows related milestones to be treated as a single milestone. For example, grouping the EndSuccess and Exception milestones is useful to indicate the completion of the process regardless of whether it completed successfully or failed. Duration calculates the time between two business milestones and is useful when reporting the time elapsed between two milestones is important. A progress dimension defines milestones and stages for a process. A progress dimension allows you to display how many processes are at an existing status at a given time. For example, a progress dimension will display how many processes are in the middle of execution, how many encountered an exception, or how many processed without an exception. Alias allows the referencing of a previously created milestone

BAM Alerts
BAM alerts allow you to configure and receive alerts related to specific changes in business data. Alerts are set up per BAM view.

BAM is based on SQL Server Reporting Services, and events are fundamentally triggered via SQL Server Notification Services.

Lets create an activity, Open Excel > Add-Ins>BAM>Activity and add RequestedDateTime, OrderTranscationID, RequestorType, OrderID, ValidationStartTime, ValidationEndTime and OrderReferenceNum as Business Data Items as shown below and complete the activity. 

Deploy the Activity using the command  bm.exe deploy-all -DefinitionFile:”BizTalkDJBAMView.xml”
Once the activity is deployed, tracking activity related tables are created in BAMPrimaryImport Database.

Tracking At Receive Port
Open Tracking Profile Editor and open the activity you just deployed. From the Event Source, select Messaging Properties Schema and Mapping the Port Start Time to RequestDateTime Activity Item. Then click on PortStartTime and Choose SetPortMapping and choose the desired Receive Port.

Now from the Event Source, select Messaging Payload and select the source schema deployed then map the TransID from schema to OrderTransID in Activity and set the port mapping similar to previous step.
Tracking At Orchestration
To track messages inside the orchestration, choose Orchestration Schedule from the Event Source and map the Receive to ValidationStartTime and Decide shape to ValidationStartTime.

In order to track any data available from the message payload or context on a specific shape, right click on the shape and choose the relevant schema and map the data to activity item.

Now Apply Tracking from Tools menu, once its deployed test the application by dropping a file. Open BAM Portal. Instead of seeing a single record in the BAM, you will see two records. One Contributed by the receive port and the other from orchestration. Ideally both should contribute to the same record.

Enable Continuation
To resolve this, continuation should be enabled between the port and process. Come back to tracking profile editor. 

Right Click the BAMActivity Node and Select New Continuation and name it as TransactionID then map the message payload TransID to this Item and set the Port. 
Again add New ContinuationID and name is TransactionID then map the TransID from Message Payload from Receive Shape on the orchestration.

You are done. Go to Tools -> Apply Tracking Profile. Test again by dropping another file. This time, you see that only one record comes for both the Receive Port and orchestration process.
 Tracking profile can be deployed using bttdeploy.exe as shown below,
Conclusion
In this article, I covered how to do E2E tracking by using continuation, now you can apply this solution to your own business scenario.

The video demonstration is available on the Youtube, here is the embedded video.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.