Acknowledgment (ACK and NACK) handling with Microsoft BizTalk Server

Ugur AGACSEVEN
Published by Ugur
Category : BizTalk
24/09/2019

Context

We have seen, as part of a client project, the requirement to manage acknowledgments (ACK) and negative acknowledgments (NACK) when sending messages. This means we need to respond differently in the event of:

  1. successfully sending a message: message backed up + flag updated in an Oracle table;
  2. a problem sending a message: no backup, Oracle table not updated + email sent.

In this article, we will look at the acknowledgment system (ACK) offered by BizTalk. We will start by implementing acknowledgments using orchestration and end with a simple demonstration.

 

Setting up acknowledgments

Before going further, it is important to stress that a custom pipeline component could equally well be used to promote the AckRequired property (a Boolean indicating whether an acknowledgment of receipt is needed) and thus dispense with orchestration. However, after various tests, we have seen that promoting the property using a pipeline component works very well for negative acknowledgments (NACK) but does not work as desired when the message has been sent correctly (ACK).

We consequently decided to opt for orchestration, because in our situation, we need to be able to handle both ACK and NACK types.

 

Orchestration in Visual Studio

ack handling in orchestration

 

  • ReceiveMsg: the message is retrieved irrespective of its type (flat file or XML);
  • ConstructMsg / MsgAssignment: a copy of the message is produced;
  • SendMsgCopy: the message is sent by selecting the Transmitted value that matches the Delivery Notification property (at the logical sender port) in order to set the AckRequired property to True;

delivery notification BizTalk Server

 

  • Catch Delivery FailureException / Terminate: the process is ended if the message is not sent successfully. For information, the exception message is:

Microsoft.XLANGs.BaseTypes.DeliveryFailureException;

  • SendBackup: the acknowledged message is backed up if, and only if, the message has been successfully sent first.

 

Example

Demonstration below with a very simple example of traffic, using FILE type transports. You are then free to adapt this principle of ACK/NACK management elsewhere as it stays the same regardless of the transport type used (SMTP, FTP, SQL, etc.).

 

BizTalk configuration

Our port list is shown below:

ack receive locations and ports BizTalk Server

 

The filters for the SendPort.ACK and SendPort.NACK ports are respectively:

ack filter ports BizTalk Server

 

The aim is to produce different responses depending on successful sending of the message or otherwise.

Binding of other ports with orchestration:

ack orchestration binding BizTalk Server

 

Result

Lastly, we will trigger the message traffic with 3 files including 1 flat file and 2 XML files:

ack BizTalk Server files in trigger

 

The result for the promoted properties AckSendPortName and AckType (generated by the DeliveryNotification=Transmitted property in the orchestration):

ack BizTalk Server promotion result

 

Note: the AckType property is set to ACK if the message reaches its destination, and to NACK if it does not.

The files for acknowledgment message routing are shown below:

ack BizTalk Server routed files

 

In our example, these files are empty but they do nonetheless equate to an acknowledgment of receipt. It would be entirely possible to use other transport types (SMTP, etc.) and to use a custom pipeline component to set up the desired responses.

The files backed up at the end of the process, for which the contents have definitely been delivered:

ack BizTalk Server backup files

 

Conclusion

As can be seen, setting up the acknowledgment system (ACK and NACK) offered by BizTalk is inexpensive and straightforward, which means we can adopt different responses depending on the successful sending of messages or otherwise.