Contact Us 1-800-596-4880

Receiving AS2 MDNs - Mule 4

The following example shows how to use Anypoint Connector for AS2 (AS2 Connector) to receive AS2 MDN (Message Disposition Notification) messages from a trading partner and, for every received MDN, log a message that contains the message payload to the Studio console.

This example is similar to the Receiving AS2 Messages example, except that in this example:

  • You use the AS2 mdn listener source instead of the As 2 listener source and set the path to /receiveMDN.

  • On the Logger properties window, you set the Message field to MDN Received: #[payload].

The following screenshot shows the Anypoint Studio app flow for this example:

Receive MDN Messages Example App Flow

To test this example:

  1. Run this app.

  2. Run the app configured in the Sending Asynchronous AS2 MDNs example.

    In the Studio console in this app, you should see a message for each received AS2 MDN that was sent asynchronously. For example:

    INFO  2022-09-09 17:15:46,409 [[MuleRuntime].uber.06: [as2-basic-example].ReceiveAsyncMDN.CPU_LITE @1369de96] [processor:
    ReceiveAsyncMDN/processors/0; event: 30609f70-307c-11ed-8f5a-38f9d3713331] org.mule.runtime.core.internal.processor.
    LoggerMessageProcessor: MDN Received!
  3. Run the app configured in the Sending Synchronous AS2 MDNs example.

    In the Studio Console in this app, you should see a message for each received AS2 MDN that was sent synchronously. For example:

    INFO  2022-09-09 17:15:46,409 [[MuleRuntime].uber.06: [as2-basic-example].ReceiveAsyncMDN.CPU_LITE @1369de96] [processor:
    ReceiveAsyncMDN/processors/0; event: 30609f70-307c-11ed-8f5a-38f9d3713331] org.mule.runtime.core.internal.processor.
    LoggerMessageProcessor: MDN Received!
If the Receipt delivery url field is not configured for the Send with Async MDN source and you are using an HTTP request, the header Receipt-Delivery-Option must be included with the As 2 mdn listener endpoint (http://localhost:8082/receiveMDN).

XML for the Receiving AS2 MDNs Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:as2-mule4="http://www.mulesoft.org/schema/mule/as2-mule4" xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/as2-mule4 http://www.mulesoft.org/schema/mule/as2-mule4/current/mule-as2-mule4.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="localhost" port="8082" />
	</http:listener-config>
	<as2-mule4:mdn-listener-config name="AS2_Connector_Mdn_listener_config" doc:name="AS2 Connector Mdn listener config" httpListenerConfig="HTTP_Listener_config" >
		<as2-mule4:self-config as2Name="partnera" x509Alias="partnera" email="support@partnera.com" />
		<as2-mule4:partner-config as2Name="partnerb" x509Alias="partnerb" email="support@partnerb.com" />
		<as2-mule4:key-store-config keystorePassword="test" keystorePath="as2/partnera.p12" privateKeyPassword="test" />
	</as2-mule4:mdn-listener-config>
	<flow name="AS2MDNListener" >
		<as2-mule4:as2-mdn-listener doc:name="As 2 mdn listener"path="/receiveMDN" config-ref="AS2_Connector_Mdn_listener_config"/>
		<logger level="INFO" doc:name="Message Received!" message="MDN Received: #[payload]"/>
	</flow>
</mule>
View on GitHub