MuleSoft Connectors: Asynchronous Responses with AS2 Receive
Requirements: /n software Connectors for MuleSoft
The /n software Connectors for MuleSoft extend the functionality of MuleSoft and provide robust enterprise-ready Internet connectivity, secure messaging, and file transfer.
Our AS2 Receive connector supports generating synchronous and asynchronous receipts. Please see the Getting Started article for more information on getting up and running with an AS2 Receive connector and HTTP Listener.
The incoming AS2 message will specify whether a receipt should be returned synchronously or asynchronously. A request for a receipt is defined by the presence of the Disposition-Notification-To and Disposition-Notification-Options headers. A request for an asynchronous receipt is defined by the presence of a Receipt-delivery-option header. For example:
Disposition-Notification-To: SomeData Disposition-Notification-Options: signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha-256 Receipt-delivery-option: http://trading.partner.com:8000
When replying to the original AS2 message with an asynchronous receipt, the server should respond with a 200 OK HTTP response. At a later time, the server should POST the receipt over a separate connection to the location specified in the original message. Below are the steps for setting up AS2 Receive to acheive this.
The default behavior of the connector is to return a receipt to the sender synchronously via the HTTP Listener. Asynchronous delivery is possible with AS2 Receive by adding an intermediate directory and separate flow to send the receipt.
To configure a project to send the receipt asynchronously, please follow the below steps.
First, open the configuration page for the connector which handles the incoming AS2 message. Set the AsyncMDNInfoDir Other setting to a path on the local filesystem where the connector can write the receipt and receipt metadata.
Next, create a new flow using a desired event source (in this case, a scheduler is used for simplicity). Add a File List connector and a For Each Scope behind it, to iterate over the stored asynchronous MDN's at the location from step one.
Next, add an AS2 Receive connector inside the For Each Scope and set the ReceiveMode to AsyncMDN. This will configure the receive connector to perform the send receipt operation for asynchronous MDN's stored in this directory.
Finally, after the MDN is successfully sent it should be deleted from the intermediate directory using a File Delete connector.
Depending on the deployment environment it may not be desirable to write files to an intermediate directory. In this case, instead of using the built-in AsyncMDN receive mode you can send the receipt using existing Mule mechanisms. After an incoming AS2 message has been processed by AS2 Receive, the attributes collection is populated with the MDN data.
#[attributes.MDNReceiptHeaders] #[attributes.MDNReceipt] #[attributes.MDNReceiptDeliveryOption]
Of course, you can save this information and complete the AS2 response out-of-band using the desired mechanisms.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at email@example.com.