Send Adapter Operations


Send adapters can perform the following operations:

  • Resubmit: void Resubmit(IBaseMessage msg, DateTime timeStamp). After a transmission failure occurs on a message, an adapter resubmits it when appropriate. This is called on a per-message basis. If a batch of messages was submitted unsuccessfully, the adapter must determine the messages causing the failure, and resubmit the ones that did not cause the batch to fail in separate calls to Resubmit. There is information at the end of this topic about how to preserve message context property values when you call Resubmit.

  • Move to Next Transport: void MoveToNextTransport(IBaseMessage msg). If a message fails during a send operation and its retry attempts have been exhausted, the adapter can send the message to the next configured transport for retransmission.

  • Suspend: void MoveToSuspendQ(IBaseMessage msg). The adapter moves a failed send message to the Suspended queue if no additional backup transport is configured. There is information at the end of this topic about how to preserve message context property values when you call Suspend.

  • Delete: void DeleteMessage(IBaseMessage msg). The adapter deletes a message after being notified by BizTalk Server of its successful transmission. Deleting a message tells BizTalk Server that the adapter is finished with the message. Generally the SubmitResponse operation is done in the same batch as its associated Delete operation.

  • Submit Response: void SubmitResponseMessage(IBaseMessage solicitMsgSent, IBaseMessage responseMsgToSubmit). The adapter submits a response to the batch to be sent back to BizTalk Server. This operation includes the original message in the call along with the response so that BizTalk Server can correlate them.

  • Cancel Response: void CancelResponseMessages(string correlationToken). If the sending of a response message needs to be canceled before the batch is submitted, the CancelResponseMessages method is used, passing in the correlation token for the associated response message to be deleted.

When calling Resubmit or Suspend on a message you may want to preserve the values of certain message context properties. You can do this by saving property values in XML format. When the message is resubmitted or suspended the corresponding properties remain available in the message context.

The following XML string describes the format in which the information is stored:

<Property name="StringProperty" nameSpace="http://MyNamespace1" vt="8">SomeString</Property>  
<Property name="IntProperty" nameSpace="" vt="3">4</Property>  
<Property name="BoolProperty" nameSpace="" vt="11">0</Property>  

This XML string is generated by the following code:

private string GetPropsToUpdateXml(int nextRetryAttempt)  
string result = "<PropertiesToUpdate><Property name=\"RetryAttempts\" nameSpace=\"\" vt=\"3\">" + nextRetryAttempt.ToString() + "</Property></PropertiesToUpdate>";  
return result;  

This string is then saved to the message context by using this code:

Message.Context.Write("PropertiesToUpdate", "", GetPropsToUpdateXml(++retryAttempt));  

When the message is resubmitted, the adapter can read this property by using the following line of code:

propValue = inmsg.Context.Read("RetryAttempts", "");  

Community Additions