Using BAM for latency tracking in a BizTalk request response scenario

April 28th, 2008

This post will try and explain how BAM tracking can be used in SOAP based request response scenario in BizTalk 2006. It important to notice that some of the issues discussed in the post are specific to the SOAP adapter and are non-issues if the scenario would for example use the the WCF adapter or similar.

Describing the scenario

In this case we have a SOAP receive port that receives a request and returns a response. The request is routed to a orchestration that calls three different send ports. These ports then sends new requests to back-end systems and returns responses (communication with back-ends systems are also SOAP based). The three responses are used to build up the final response that is then returned to original receive port as a final response.

Our goal is to track the duration between the request and response on each of the ports. The idea is also to find a solution and tracking model that doesn’t have to change if we add or remove ports or add similar processes to track.

scenario

Defining and deploying the tracking model

We’ll start by defining our tracking model in Excel. Our activity contains of the following items:

  • InterchangeId (data item)
    As we won’t correlate all the tracking point into one single row (that would break the goal of having one model for all processes, the model would then have to be specific for one process and it’s specific ports) the interchange id will then tell us what different rows belong together and that describes one process.
  • ReceivePortName (data item)
    The name of the receive port.
  • Request (milestone item)
    The time the request was either sent or received (depending on if we track a port that received/sent the request using a receive port or send port).
  • Response (milestone item)
    The time the response was either sent or received (depending on if we track a port that received/sent it’s response on a receive port or send port).
  • SendPortName (data item)
    The name of the send port.

After we described the model it’s time to export it to an XML representation and then to use the BM tool to deploy it and generate the BAM database infrastructure. You’ll find some nice info on this here.

Using the Tracking Profile Editor to bind the model

Next step is to bind the model to the implementation using the Tracking Profile Editor. The figure below shows the different properties that were used. Notice that none of the items was bound to the actual orchestration context. All properties are general properties that we track on the ports. This is important as that gives us the possibility to just add and remove ports to change the tracking.

tracking profile using continuation

The next figure shows how the tracking of the request milestone event actually happens on either the RP1 port or on any of the three different send ports! If we developed a new process using other ports we could just add it here, no new model required.

tracking profile configure ports 2

What about the continuation then?

Our final problem is that unless we somehow correlate our request tracking point with our receive tracking point the receive we’ll end up with each tracking point spread over several different rows. In the example below I’ve marked the request for the RP01 port and the response event on the same port.

bam portal split results

The reason for this is of course that BAM doesn’t have a context for the two tracking points and doesn’t know that actually belongs together. This differs from tracking in a orchestration were we always are in a context (the context of the orchestration), it’s then easy for BAM to understand that we like to view all the tracking point as one row – when tracking on ports it’s different. Continuation helps us tell BAM that we like have a context and correlate these two points.

tracking profile using continuation 2

In our case ServiceID is the prefect candidate for correlating the two points. A request and a response will have the same service id. In an other situation we could just as well have used a value from inside the message (say for example an invoice id).

The result is one single row for the request response for each port. So in our case a complete process (a complete interchange) is shown on four rows (one row for each of the ports). In the example below the first rows shows us the complete duration (and the other tracking data) between the request response to the client. The other rows show the duration for the send ports communication with the back-ends systems.

bam portal complete results

This model might not be optimal in an other scenario where your process are more fixed and you can then create a tracking model that is more specific to you actual process. But this solution meets our design goal as we’re now able to just add and remove port using the tracking profiler to track new port in completely new processes without having to go back and change the tracking model.

note  NOTE: When configuring BAM to track a port the MessageType is actually promoted. This causes some problems in combination with the SOAP based ports that have been published using the Web Services Publishing Wizard. Saravana writes about this here and all his articles on this subject is a must read when working with SOAP ports. The problem however comes down to that the Web Services Publishing Wizard generates code that puts the wrong DocumentSpecName in the message context and that causes the XmlDisassembler to fail (it tricks the XmlDisassembler to look for a MessageType that doesn’t exists).

This usually isn’t a problem (unless you like to use a map on a port) but as BAM will force the port to promote the MessageType based on the DocumentSpecName we’ll have to fix this. Saravana has two solutions to the problem and I find the one that replaces the DocumentSpecName with a null value and lets the XmlDisassembler find the MessageType to work well.

7 Responses to “Using BAM for latency tracking in a BizTalk request response scenario”

  1. OldDirtyFish Says:

    Very Good Richard!!!

  2. MrE Says:

    Hi Richard,

    Thanks for an interesting article. I want to use BAM to track integrations in messaging scenarios. My approach is very similar to yours but I think I’m doing something wrong setting my continuation. The problem appears when I have a one to many scenarios where I get only one row tracked. Can you tell how you mapped the ServiceID in the TPE (continuation & continautionID) and on which ports? I’m using InterchangeID for the purpose of the continuation.

    Regards,

  3. Richard Says:

    @MrE: I’m don’t really understand what it’s you’re trying to achieve. Feel free to contact me via email and I’ll try and help you.

  4. MrE Says:

    Can you please give your email address and I’ll contact you.

    Thanks!

  5. bhaskar Says:

    HI,
    I have two orchestrations which pick up data from same receive port with different receive locations. At first, the first orchestration receives files from that port and then after processing drops the file at a location from which the second orchestration picks up the file. These all three locations are in same port.

    Now, I am using single BAM activity to capture the Orchestration Start Time of both of these orchestrations and as a Continuation, I used almost every possible Context properties including InterchangeId, Message id etc. But data are coming in two different rows in BAM tables. That means I am unable to make continuation between these two orchestraions.

    Please suggest to solve this problem.

    Regards,
    Bhaskar

  6. Genious Says:

    thanks richard,

    v nice article. but my scenario is totally different.

    hope i will find some good tutorial

    thanks,

  7. Richard Says:

    @bhaskar: I don’t see why I wouldn’t work using for example the Interchange ID … Have you checked the value of it to make sure it same for all messages in your process?

Leave a Reply