Wed, Apr 7 2010 3:25 PM Vincent Scheel

BizTalk BAM event not written from PipelineComponent when port fails

When developing a custom PipelineComponent I spend quite a while overlooking the obvious. For all those who also overlook this:

When writing BAM from a PipelineComponent it is a good practice to use the PipelineContext.GetEventStream() method to get the BAM eventstream. This way your BAM events will piggyback ride along on the SQL calls already made by the BizTalk messaging engine.

Firstly I wrote a little console app to create some BAM instances from code using a DirectEventStream. When this gave the results I wanted, I developed the PipelineComponent using the same code, but with the MessagingEventstream instead of the DirectEventStream. After I wrote the PipelineComponent and created a little sample with just a receive port (which would cause a routing failure), the BAM instance did not show up in the database.

I was not sure if the PipelineContext.GetEventStream() method worked correctly, so I tried to use the DirectEventStream in the PipelineComponent to see if that would work. It did. After that I added some Debug statements in the component using the correct EventStream and ran it again. All the debug statements were hit, but nothing showed up in the database.

Then it suddenly dawned on me... Since the port was failing due to the routing failure, maybe the transaction of the MessagingEventstream was cancelled? After adding a send port to solve the routing failure, the next BAM activity did show up.

So, if you use the PipelineContext.GetEventStream() method it will only store information if the entire receive port was executed succesfully. If this is your requirement, that is fine, but if you want to store everything that goes through the pipeline, don't use the MessagingEventStream.

Update: after the comment by Thiago Almeida I tried the same for a send port. In a send port the BAM event is written even if the send port fails. Also a thing to keep in mind.

Filed under: , , ,

# re: BizTalk BAM event not written from PipelineComponent when port fails

Wednesday, April 07, 2010 11:20 PM by Thiago Almeida

Nice to know Vincent, and it makes sense. It uses the same transaction as the endpoint manager does to write the message to the message box, and if it fails it gets rolled back.

I wrote a post talking about using the underlying connection on a receive port:

connectedthoughts.wordpress.com/.../hooking-into-biztalks-underlying-transaction-in-your-custom-receive-pipeline-component

Have you tried this on a send port as well  to see if it also rolls back? From my experience while writing that blog post I was only able to hook into the transaction on the receive pipeline.

Regards,

Thiago Almeida

# re: BizTalk BAM event not written from PipelineComponent when port fails

Thursday, April 08, 2010 8:52 AM by Vincent Scheel

Thanks for your comment Thiago. I just tried and I do not get the same behaviour with a send port. The send port writes to BAM even if the port fails.

So I have the same finding as you!

Regards,

Vincent Scheel

# re: BizTalk BAM event not written from PipelineComponent when port fails

Thursday, April 08, 2010 10:25 AM by Patrick Wellink

Hee Vince,

Nice to see you figured it out by yourself. (could have given me a call though...)

The same behaviour you get with inspecting the message. Say you have three pipecomponents and each alters the message. You would expect that if the pipeline fails on pipecomp 3 you would get a message altered by pipecomp 1 and 2. However the original incoming message (so before it enters the pipeline) is stored. Funny enough though... Any context props that you modify and add are stored. So context is not rolled back ( I use exactly this functionalitu in BBP for resubmits on failed messages).

Anyway back to your issue :

I believe that that last issue ( write to bam if send failes is solved with SP1)

see : 942024  (support.microsoft.com/.../942024 ) FIX: A Business Activity Monitoring (BAM) activity is not rolled back when the send port fails in delivering the output message in BizTalk Server 2006

However DO NOT INSTALL SP1 !!!!!!!!

it's utter crap..... As far as my experience goes it breaks the following :

1. Disassembly in receive pipelines

2. The complete WCF database stuff....

3. And there is more

Nice to know you'r still BizTalking........ !!!!!!!!!!!1

# re: BizTalk BAM event not written from PipelineComponent when port fails

Tuesday, September 21, 2010 9:53 AM by air max

It is my pleasure to read your article, your article is very wonderful. Thank you for sharing!

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 2 and 1 and type the answer here: