BizTalk Server: The BAM API objects…

  • Sandro Pereira
  • Aug 20, 2010
  • 3 min read

When your business process moves outside of BizTalk Server—into a Web API, a Windows Service, or a custom portal—you can no longer use the Tracking Profile Editor (TPE). To maintain visibility, you must use the BAM API.

To use the BAM API, you first need to understand the core objects located in the Microsoft.BizTalk.Bam.EventObservation namespace.

The EventStream Class

The EventStream class is the abstract base for sending information to the BAM database. There are two primary implementations you will use, depending on your performance and consistency needs.

The BAM API defines four main classes:

  • DirectEventStream: used in a .NET application to do a buffered write of data to BAM.
  • BufferedEventStream: used in a .NET application to do an unbuffered write of data to BAM.
  • OrchestrationEventStream: used when writing to BAM programmatically within an orchestration; Provides transactional consistency with the orchestration.
  • MessagingEventStream: used when writing to BAM programmatically within a pipeline; Provides transactional consistency with the messaging engine.

All of these classes are derived from the base class EventStream.

📝 One-Minute Brief

While the Tracking Profile Editor (TPE) is the standard for BizTalk, the BAM API is the key to tracking events from external .NET applications. This guide breaks down the essential objects in the Microsoft.BizTalk.Bam.EventObservation namespace, including the DirectEventStream for synchronous tracking and the BufferedEventStream for high-performance, asynchronous scenarios. Master these objects to integrate non-BizTalk processes into your BAM activities seamlessly.

Differences between BufferedEventStream and DirectEventStream

  • BufferedEventStream: The BufferedEventStream is designed for high-performance enterprise applications. It stores the tracking data in the BizTalkMsgBoxDb first, and the “BAM Event Bus” service moves it to the BAM database later.
    • Is asynchronous
    • When you update a BufferedEventStream, the update is cached and written later.
    • The BufferedEventStream takes advantage of the cache to improve performance
    • Best for: High-volume applications where you don’t want tracking to impact the performance of the main business logic.
    • Risk: There is a slight delay (latency) before data appears in the BAM Portal.
  • DirectEventStream: The DirectEventStream writes data directly to the BAMPrimaryImport database in real-time.
    • Is synchronous
    • When you execute an update, the call won’t return until the database write is committed
    • If your application cannot afford to lose data in a server crash, use this class
    • Best for: Scenarios where data must be visible in the BAM Portal immediately.
    • Risk: If the SQL Server is slow or down, your application will wait (synchronous) and potentially time out.

Advantages of using OrchestrationEventStream

  • Performance: It can piggyback its database writes on the orchestration persistence points for maximum performance
  • Consistency: because it writes during orchestration persistence points, even in the event of the server crash, the state of the orchestration recorded by BAM is guaranteed to be consistent with the last orchestration persistence point

Choosing the right BAM API object is a balance between performance and visibility. By using BufferedEventStream, you ensure that your monitoring logic never becomes a bottleneck for your business applications.

Thanks for Buying me a coffe

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top