Delivery Notification Inside an Orchestration

This sample shows how to use Delivery Notification on a Send Port to catch and react to adapter send errors inside an Orchestration.

Key Take Home Points:
– Delivery Notification is not available on Early Bound Ports.
– Must import System.Web.Services to cast the SOAP exception
– Set Send Port retries to 0
– Must use a Synchronized scope
– Does not work with Send Port Groups

Get more information from the original blog post on this topic: https://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/08/02/biztalk-delivery-notification-and-nack-sample.aspx

Mapping in Send Ports with Delivery Notification

I have talked in the past about NACKs.  These are great little messages that allow you to receive the status of your sent messages inside your Orchestration.  For more information on NACKs, please see my earlier post and sample.



The problem I want to point out here occurs if you want to map on the Send Port and have Delivery Notification set to Transmitted inside the Orchestration.  I have found that everything works great as long as your map is successful.  ACKs and NACKs are returned as expected.



If the map on the Sent Port fails is when you have a problem.  In this case, no ACK or NACK is sent back to the Orchestration since the message never reached the pipeline.  The Orchestration will remain running and eventually dehydrate still waiting hopelessly for the ACK or NACK to return.  In addition, the message that was sent gets set to Active and the status is set to Delivered, not consumed.  I have not been able to get the sent message to do anything other then Terminate and even that took some effort.



I have updated my NACK sample to include a map that fails in case you want to test it out for yourself.  The updated download is available here.  Just add the map to your Send Port.  If you want to create your own map, just add a scripting functoid that throws an exception.



Take Away: Be mindful of mapping in the Send Ports if Delivery Notification will be transmitted back to the Orchestration.

BizTalk Delivery Notification and NACK Sample

Did anyone read Kevin Smith’s blog on ACK/NACK and run out to try it?  Well, I did and found it a more time consuming then I expected.  I have put together a sample that shows how to catch the SOAP exception and get access to the error message.  I hope that after looking at this sample Kevin’s excellent post on NACK’s will make a little more sense.  It did for me.

DOWNLOAD: Get the sample here!

Set-up is easy, just unzip the SampleNACK folder and put it on your C: drive.  Then, build and deploy the SampleNACK project. You will need to manually create a Send Port.  I set up a File Send Port going to c:\some_location_that_does_not_exist.  Set retries to 0.  To run it, drop the StartFile.xml message into c:\SampleNACK\In.  Your NACK will show up in c:\SampleNACK\Out.  Do not forget to look inside the expressions shapes inside the Orchestration for comments.  If all else fails, read the ReadMe.txt file. 

CRITICAL: Getting at the HTTP error using Delivery Notification will not work for transport type of HTTP or SOAP due to an “issue”.  For more information please see Microsoft KB840008.

Key Take Home Points:
– Delivery Notification is not available on Early Bound Ports.
– Must import System.Web.Services to cast the SOAP exception
– Set Send Port retries to 0
– Must use a Synchronized scope

Under the covers:
Ok, so you ask what is BizTalk doing inside the little Delivery Notification property? Keep in mind this is my interpretation. 

When a message is sent through a send port with Delivery Notification set to transmitted, a correlation set is initialized.  A correlation token is assigned to the outbound message.  A subscription is started based on this correlation token.  This token is stored in the context property of the ACK/NACK and promoted.  When the ACK/NACK is returned, it is routed back to the calling Orchestration.  You get all this just by setting a little property to “Transmitted”!  Cool!

Take Away: Delivery Notification is an easy way to catch exceptions as long as you understand how to get at the error message.