Put Some "BAM" in Your Next BizTalk 2004 Project, Page 2
BAM Databases and DTS Packages
Figure 10 displays the tables created in the BAMPrimaryImport database after the BM.EXE utility executes.
Figure 10. Tables Created in the BAMPrimaryImport Database
BAM will copy the data to a particular table depending on whether an Activity is "Active" or "Completed." Tables are created with the appropriate keys and unique indexes depending on how you call the API or define the Tracking Profile (more on the BAM API and Tracking Profiles later). Figure 11 shows some data from one of the tables in the sample application.
Figure 11. Data from One of the Tables
In addition to tables, BAM also creates a set of stored procedures for use by the BAM API (see Figure 12).
Figure 12. BAM Stored Procedures
Figure 13 lists the DTS packages created when the BAM Definition is deployed.
Figure 13. DTS Packages
The DTS Packages perform actions like archiving and populating Analysis Services Cubes. You can modify the packages to perform other operations.
Once you've created and deployed your BAM Definition, you have two implementation options:
- Use the BAM API to collect your BAM Activity Items.
- Collect your BAM Activity Items using a Tracking Profile.
Calling the BAM API
As stated earlier, the BAM API has a synchronous (DirectEventStream) and an asynchronous (BufferedEventStream) form. The following code from an Expression Icon in the Sample Orchestration illustrates how you invoke the BAM API:
bamDirectEvent = new Microsoft.BizTalk.Bam.EventObservation. DirectEventStream("Integrated Security=SSPI;Data Source=.; Initial Catalog=BAMPrimaryImport",0); bamDirectEvent.BeginActivity("IterationTrackingDirect",IDValue); bamDirectEvent.UpdateActivity("IterationTrackingDirect", IDValue,"IDValue",IDValue,"IterationNumber",NumIterations, "Descrip",Descrip,"RecordDate",System.DateTime.Now); bamDirectEvent.EndActivity("IterationTrackingDirect",IDValue);
The DirectEventStream and BufferedEventStream have the same set of functions. BeginActivity initiates the logging, UpdateActivity continues the logging, and EndActivity ends the logging.
The main differences between DirectEventStream and BufferedEventStream are:
- The BufferedEventStream uses the BizTalk Messagebox and then writes the logging data to the SQL database.
- DirectEventStream writes directly to the SQL database.
The BAM API classes are located in the "C:\Program Files\Microsoft BizTalk Server 2004\Tracking" folder, in an Assembly called Microsoft.BizTalk.BAM.EventObservation.
The BAM API also includes functionality for redirecting BAM Activity to other data sources in a set of BAM Interceptor functions and Interfaces.
As stated earlier, the BAM API was one option for implementing BAM. The easiest way to implement BAM in your orchestration is to create a Tracking Profile.
Setting Up a Tracking Profile
The Tracking Profile Editor is one of the BizTalk administration tools. Select File -> New, and then select your Orchestration to create a new Tracking Profile. A mock-up of your Orchestration will appear in the tool (see Figure 14).
Figure 14. Tracking Profile Editor
To link your Orchestration to an Activity Definition, right-click on the Orchestration and select Import Activity Definition. When you import the Activity Definition, a screen like the one in Figure 15 will appear.
Figure 15. Import the Activity Definition
Map the Activity Items to steps in your orchestration in the following manner:
- Milestone Items can be mapped by dragging and dropping the Orchestration Icon you want to relate to the milestone.
- To map other Items, you must connect the Item to data in a message. To do this, right-click on Icons (which create messages), select the appropriate schema, and drag the appropriate element in the message to the Activity Item.
To deploy the Profile, select the Deploy option on the File menu.
Tracking Profiles still utilize the BAM API. When you use a Tracking Profile, instead of writing code BizTalk performs the API calls for you.
Now that you have completed your BAM implementation, consider some final issues.
Using What You've Logged
You won't realize the true value of BAM until you use the BAM logging data with tools like Reporting Services and Notification Services.
If you've included things such as Purchase Orders and other keys in your BAM data, you can combine the BAM data with data in other databases. For example, you can modify the DTS packages to divert your BAM data to another database that includes more detailed information about your business process, and then generate reports using Reporting Services.
If you want to generate special notifications based on your data, you can build the Notification using Notification Services.
Any other tool capable of reading SQL Server data also can utilize the BAM logged data. If you want to experiment, start with the BAM Definition spreadsheet. The spreadsheet has built-in functionality for reading the Analysis Services Cube data. You can use the spreadsheet to prototype your ideas.
Record Your BizTalk Orchestrations' Progress
BAM allows a developer to record the progress of your BizTalk Orchestrations for consumption by tools such as Reporting Services. BAM is straightforward to set up, and it can execute in a synchronous and asynchronous fashion depending on your performance requirements. Finally, BAM can be customized to write data to other databases to satisfy any reporting requirements.
- BizTalk 2004 Unleashed, Woodgate 2004
- "BizTalk Server 2004: A Review of the Business Activity Monitoring (BAM) Features"
Download the Code
To download the accompanying source code for this article, click here.
About the Author
Jeffrey Juday is a software developer with Crowe Chizek in South Bend, Indiana. He has been developing software with Microsoft tools for more than 12 years in a variety of industries. Jeff currently builds solutions using BizTalk 2004, ASP.NET, SharePoint, and SQL Server 2000. You can reach Jeff at email@example.com.
Page 2 of 2