Welcome to MSDN Blogs Sign in | Join | Help

Fun with BAM and orchestration execution time

Abstract: I’ve using BAM to measure execution time in some orchestrations. I cannot use HAT because I needed to do some calculations to rest waiting time of the external processes. It’s extremely easy. Things get funny when we needed to get more that one row per orchestration instance (because of loops which are there…)


Today I’ve doing this BAM at a customer’s. I’m going back home in a high velocity train, but it’s a long trip, so I think this post is going to get long… I’ll divide it in 2 parts:

Part 1- The easy sample
The scenario is quite simple: some orchestrations provide a synchronous web service façade for a legacy system. The logic for integration with lecagy includes files interchange, sockets comminications and some transformations from/to Xml and HL7 flat files.
What we want: stress the solution and get detailed information about orchestration execution time. This execution measured time should not include web service communications or file interchange with the legacy system, because the intention is to measure BizTalk performance, regardless of network bandwidth or external dependencies.

Here is the sample:


 

simple orchestration sample

In the simplified sample (actual processes are a little more complex :-), we must measure time between start (Receive 1) and Send 1, and time between Receive 2 and last send back (Send 2). Time between Send 1 and Receive 2 must be taken away.

All this information is in tracking database, and can be queried at a basic level with HAT. Probably it’s not very complex to query the tracking database to get these values. Since each shape has a start and end time, it’s just a question of making the right queries.
Anyways, as I have only one working day to prepare the environment for the tests, I don’t have time to study the tracking DB internals. I’ve done the easy way: BAM milestones. It’s easy because there’s no need to know about BizTalk internals (tracking db design) and flexible because BAM definitions can be designed and deployed independently to the orchestration development.

So, I’ll show how to do it in just 10 minutes (for the above sample):

1- Create BAM definition with the BAM Structures Mega Designer (aka the little Excel sheet :-). These definitions include 4 Activity Items, all of them as milestones. I’ll not use duration view items to catch intervals, instead I’ll do a Transact/SQL DATEDIFF later.
Time estimated: 3 minutes

2- Export the BAM definition to an Xml file, and deploy it in the server with BAM Management Utility (bm.exe).
Use the Tracking Profile Editor to assign each activity item to orchestration shapes.
Don’t forget to assign an Activity Id, tipically an Id field takes from the message schema.
Deploy the profiles to the server.
Time estimated: 3 minutes

3- Only have 4 minutes left, so I’ll assume there is some test automation :-).
Launch the tests (with NUnit in my case).
Open SQL Server Query Analyzer, connect to the DB server, switch to the BAMPrimaryImport database and open the corresponding BAM view. There you can see the milestones catched.
Now you can calculate execution times with basic date adds and rests. It you want to do it with SQL DATEDIFFs, execute something like this:
SELECT [fields],
DATEDIFF(ms, [Milestone1], [Milestone2]) As Segment1,
DATEDIFF(ms, [Milestone3], [Milestone4]) As Segment2,
(Segment1+Segment2) As TotalTime
Time estimated: 5 minutes (ouch, 1 minute late!)

well, actually the last part is not true… you cannot use Segment1 and Segment2 aliases in the last line, so you’ll need to repeat the DATEDIFF statements. I've included in this way to improve readability.
Also, another nice way to do it is query the standard views with Excel and play with columns and formulas.

Now we are ready to launch stress tests and query orchestration execution times easily. The stress tests will be launched via Application Center Test, so we can control concurrent users, test timing, etc.

Part 2- I have a Loop and BAM Activity items cannot be assigned
The second orchestration has been more tricky. It’s a 1-to-many façade, so it has a loop to send many messages to the legacy systems. Something like:

 

The problem: Activity items cannot be assigned to shapes inside the loop. Why? because each activity item is a row, and the Activity Id is taken from a message field that is unique for the orchestration.
The solution: use the API to add new BAM rows for each loop iteration. The Activity Id of each child-row will be the parent Activity Id plus the counter of the loop, so they can be related easily in a query.
The BAM API is very straightforward. One object, three methods: The EventStream object is used to create a new activity (BeginActivity method), update rows (UpdateActivity) of close the activity (EndActivity).
You can use a DirectEventStream object that writes the data in the BAMPrimaryImport database directly. This can impact the performance because it’s synchronous.
You can either use the BufferedEventStream object that use a asynchronous store-and-forward. It does not guarantee that the event will be inserted in BAM immediately, but it does not affect caller performance.
Here is the tricky thing: There is a property called ConnectionString that points to the database. If you use the DirectEventStream, ConnectionString points to BAMPrimaryImport database. But if you use BufferedEventStream, its ConnectionString points to the MessageBox database, because it’s used for store-and-forward.

My code between the orchestration and a helper component does more or less the following:
For each loop iteration:
- Begin an new Activity, using [ActivityId].[LoopCounter]
- Update with a milestone before sending to legacy
- Update with a milestone after receiving from legacy
- Close the Activity


So, for each orchestration instance, I have in the BAM database:
- One row with
    - Orchestration Activity Id
    - Milestones for BeginOrch and EndOrch
- Many “child” rows (the loop) with
    - Orchestration Activity Id + Counter
    - Milestones for BeginSend and EndReceive

The query to aggregate everything (courtesy of eXtreme.net, because I don’t have quick Transact/SQL skills), return a single row with the calculated fields for TotalTime and TotalTimeWithoutLegacyStuff. It uses DATEDIFF for the differences, and SUBSTRING to relate different parent and child Activity IDs

 

Published Tuesday, June 28, 2005 8:42 AM by dhtoran

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Using BAM to get orchestration execution times

Thursday, June 30, 2005 5:41 AM by eXtreme .NET

# re: Fun with BAM and orchestration execution time

Friday, September 09, 2005 11:07 AM by Senthil

Its good one. Are you maintining two activity tables (like parent and child) with two milestone or, only one activity with two milestone, where you update both parent and child rows in the same activity table.

# Mortgage Loan

Tuesday, March 21, 2006 8:59 PM by Mortgage Loan
Your site is very informational for me. Nice work.

# google pr main

Tuesday, April 18, 2006 6:17 AM by google pr main
Welcome!!! http://www.areaseo.com/contacts/">http://www.areaseo.com/contacts/ google pr. [URL=http://www.areaseo.com]pagerank 5[/URL]: Search Engine Optimization, Professional SEO, pagerank algorithm. Also [url=http://www.areaseo.com]online pr16[/url] from google pr .

# google pr main

Tuesday, April 18, 2006 6:17 AM by google pr main
hello! http://www.areaseo.com/contacts/ google pr. Search Engine Optimization, Professional SEO, pagerank algorithm. From google pr .

# google pr main

Monday, April 24, 2006 8:35 AM by google pr main
Welcome!!! http://www.areaseo.com/contacts/">http://www.areaseo.com/contacts/ google pr. [URL=http://www.areaseo.com]pagerank 5[/URL]: Web Site Analysis, SE marketing, High Rankings. Also [url=http://www.areaseo.com]online pr16[/url] from google pr .

# google pr main

Monday, April 24, 2006 8:35 AM by google pr main
hello! http://www.areaseo.com/contacts/ google pr. Web Site Analysis, SE marketing, High Rankings. From google pr .

# afv9a3x@google.com

Monday, April 24, 2006 8:35 AM by afv9a3x@google.com
online directory main

# buy xanax

Sunday, June 04, 2006 2:43 PM by buy xanax
i like your website very much but please do get us more information about it

# re: Fun with BAM and orchestration execution time

Sunday, November 05, 2006 11:55 AM by Agias

Really great site

<a href="http://used-cars.ppkkj.info">used cars</a>

# doyen Stuttgart

Wednesday, November 15, 2006 11:29 AM by doyen Stuttgart

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.bookshotel.info/polygeny_Germany/homicidal_Baden-W%C3%BCrttemberg/doyen_Stuttgart_1.html

# re: Fun with BAM and orchestration execution time

Friday, November 24, 2006 10:20 PM by story swinger

Nice site... http://story-swinger.ks0dhs.info <a href=http://story-swinger.ks0dhs.info> story swinger </a>

# ordinand Llandudno

Tuesday, December 05, 2006 2:06 AM by ordinand Llandudno

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.hotelscare.info/virulent_United%20Kingdom/heliochromy_Wales/ordinand_Llandudno_1.html

# re: Fun with BAM and orchestration execution time

Wednesday, December 06, 2006 6:21 PM by wireless

Nice site... http://cingular-wireless-customer-service.pivppp.info <a href=http://cingular-wireless-customer-service.pivppp.info > cingular wireless customer service </a>

[url=http://cingular-wireless-customer-service.pivppp.info ] cingular wireless customer service [/url]

# re: Fun with BAM and orchestration execution time

Tuesday, December 12, 2006 7:19 AM by Agias

Really great site

<a href=" http://hosting.blogpostworld.org "> hosting</a>

# re: Fun with BAM and orchestration execution time

Wednesday, December 13, 2006 10:30 AM by Anderson

I just don't have much to say recently, but whatever.

<a href='http://web-hosting.blogpostworld.org/best-web-hosting-company.html'>best web hosting company</a>

# re: Fun with BAM and orchestration execution time

Sunday, December 17, 2006 11:34 PM by Hyttep

When all else fails, read the instructions

<a href=' http://astrology.blogpostworld.org/astrology-compatibility-chart.html '>astrology compatibility chart</a>[url=http://astrology.blogpostworld.org/astrology-compatibility-chart.html]astrology compatibility chart[/url]

# re: Fun with BAM and orchestration execution time

Sunday, December 24, 2006 7:19 PM by HoodiaDietPills

# stink Thira

Tuesday, January 30, 2007 4:54 AM by stink Thira

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.businesszs.info/unbraid_Greece/ore_Aegean%20Islands/stink_Thira_1.html

# re: Fun with BAM and orchestration execution time

Tuesday, February 13, 2007 1:05 PM by car

Nice site

<a href= http://tsbgyk3q.tripod.com/donate-used-car/car-donate-infocus-used.html >car donate infocus used</a>

# re: Fun with BAM and orchestration execution time

Friday, February 23, 2007 3:50 PM by car

Nice site

<a href= http://used-car-phoenix.cashwits.org/map.html >car used</a>

# yack Prague

Thursday, March 22, 2007 3:29 AM by yack Prague

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.jobznews.info/eldest_Czech%20Republic/astral_West%20Czech/yack_Prague_1.html

# stroma Limerick

Thursday, March 29, 2007 6:36 AM by stroma Limerick

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.globalworkz.info/wot_Republic%20of%20Ireland/guy_Munster/stroma_Limerick_1.html

# Leipzig Jobs

Thursday, March 29, 2007 8:11 AM by United Kingdom

BizTalk, EAI, BPM, SO/A and related technologies

I do not agree. Go to http://www.jobzworks.info

# re: Fun with BAM and orchestration execution time

Sunday, April 01, 2007 2:20 PM by diet

Nice site

<a href="http://tradewits.org/dog-food-natural ">dog food natural</a>

# re: Fun with BAM and orchestration execution time

Saturday, April 07, 2007 11:05 AM by diet

Nice site

<a href=" http://zr2d4nmn.tripod.com/buy-online-wii "> buy online wii</a>

# re: Fun with BAM and orchestration execution time

Sunday, April 15, 2007 1:20 PM by ...

Stupore! Amo questo luogo!:)))))))

# re: Fun with BAM and orchestration execution time

Monday, April 16, 2007 5:18 PM by ...

pagine piuttosto informative, piacevoli =)

# Good site,Chauncey Wilson

Wednesday, April 18, 2007 8:23 PM by healthtak,healthtak,healthtak

The Best Catalog.

<a href=http://healthpiece.info/>Real">http://healthpiece.info/>Real Catalog</a>[url=http://healthpiece.info/]The Real Catalog[/url]

# Good site,Ginny Redish

Wednesday, April 18, 2007 9:44 PM by healthcvx,healthcvx,healthcvx

The Best Catalog.

<a href=http://healthpiece.info/>Real">http://healthpiece.info/>Real Catalog</a>[url=http://healthpiece.info/]The Real Catalog[/url]

# Hi everybody! Wanna see my cool pages? Visit my sites, please:,Good site

Hi everybody! Wanna see my cool pages? Visit my sites, please:

# Cars &raquo; David Hurtado&#8217;s Integration Traces : Fun with BAM and orchestration &#8230;

# Boxing &raquo; David Hurtado&#8217;s Integration Traces : Fun with BAM and orchestration &#8230;

# Boxing &raquo; David Hurtado&#8217;s Integration Traces : Fun with BAM and orchestration &#8230;

# Cars &raquo; David Hurtado&#8217;s Integration Traces : Fun with BAM and orchestration &#8230;

# College Fun Facts &raquo; David Hurtado&#8217;s Integration Traces : Fun with BAM and orchestration &#8230;

# Good site

Monday, August 04, 2008 1:01 AM by fabiola-fu

<a href= http://index1.akkunt.com >2005 north carolina storm damage</a> <a href= http://index2.akkunt.com >golf at wailea emerald course</a> <a href= http://index3.akkunt.com >custom embroydery patches</a> <a href= http://index4.akkunt.com >george washington 500 000 loan from penn farmer</a> <a href= http://index5.akkunt.com >david horn</a>

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker