This article describes how an ESB Proxy Service for a SOAP service could be deployed on the Free and Open Source UltraESB, to respond back to the client immediately once the response becomes available, but then post a copy of the response via an asynchronous email - without affecting the performance of the main message flow.
Originated by a proof-of-concept for a large telecom company, this scenario is now distributed as Sample #502 with the UltraESB 1.2.0 or later. A Web Service client makes a request on a Proxy Service hosted on the ESB, which will pass the message to the actual SOAP service implementation. The response received is sent back to the client immediately. A copy of the response is also pushed into a JMS Queue. A second proxy service polls the JMS Queue, and emails the messages asynchronously.
This example uses Apache ActiveMQ as the JMS Provider, and starts up an embedded instance of Apache ActiveMQ within the UltraESB, using the ActiveMQ Spring configuration mechanism.
The SOAP Proxy Service
The Proxy service exposed to the client is exposed over the HTTP transport, on port 8280 [See 1]. This Proxy service uses the WSDL and Endpoint URL of the 'SimpleStockQuoteService' distributed with the UltraESB for testing. To start this sample service, use the graphical SOA ToolBox  utility, and start its sample Jetty server. The proxy service definition is simple and straightforward as shown below.
<u:property name="wsdlURL" value="http://localhost:9000/service/SimpleStockQuoteService?wsdl"/>
A message received by the 'soap-proxy' is targeted at the inDestination - which will forward it to the address
Although not shown in this example, an optional inSequence could perform any function on the received message (e.g. transform, route, log, save to a database etc or anything else) if desired. A response received from the remote SOAP service is now handled by the outSequence. This specifies two lines of Java code specified as part of the configuration - to send this response message back to the original client, as well as the endpoint 'jmsQueue' - which is a JMS destination for the Queue with JNDI name 'Q.jmsPending'.
Starting up an embedded ActiveMQ JMS Provider
As the UltraESB configuration is a Spring configuration file, we can easily start an embedded ActiveMQ JMS provider instance by including the following configuration snippet.
<amq:broker useJmx="false" persistent="false">
The JMS Listener and SMTP sender
Now we define the second proxy service which will poll the JMS destination Queue, and send these messags via SMTP using Gmail.
<u:property name="destinationName" value="Q.jmsPending"/>
logger.info("Processing queued message from JMS and sending email..");
msg.addMessageProperty("subject", "Custom Subject for Response");
msg.setDestinationURL("mailto:firstname.lastname@example.org"); // <-- REPLACE THIS
<!--Sends email using the SMTP configuration defined as 'smtp-email', to the 'default' destination of the message-->
Again, the configuration is concise and simple to understand. The 'jmsToEmail' Proxy service polls the JMS destination 'Q.jmsPending', and the received messages are processed with the Java code snippet specified in the inSequence. The sample demonstrates how a custom 'Subject' is set for the email, but uses a hard coded destination address in this example, although it could easily be picked up by other means in a real world scenario. The message is set the destination address as a 'mailto:' address, and the UltraESB sends this message out using the SMTP transport sender configuration configured [See 1]
Trying out the sample
1. Configure the SMTP credentials as necessary in the file samples/conf/ultra-sample-502.xml. The sample configuration has been written to use the Gmail SMTP Server. Check lines commented as "REPLACE THIS"
2. Start the UltraESB sample #502 as follows: ultraesb-1.2.0/bin$ ./ultraesb.sh -sample 502
3. Start the SOA ToolBox as : ultraesb-1.2.0/bin$ ./toolbox.sh and start the sample Jetty Server
4. Start the HTTP/S client from the ToolBox. Select message from Preset "1", and set URL as "http://localhost:8280/service/soap-proxy" and send the request. You will immediately see the response from the ToolBox.
5. You should see the line "INFO sequence Processing queued message from JMS and sending email.." as the JMS destination is polled and the email is being sent, and the response would be received via the specified email account as shown below.
Load Testing the scenario
The ToolBox includes a HTTP/S load test client that could be used to simulate thousands of concurrent users making thousands of requests in iteration. Using the 'JavaBench' load testing module of the UltraESB you can test this scenario with your desired load levels - as long as your JMS provider and Email server tolerates.
Check http://esbperformance.org for information on load testing ESB use cases
 UltraESB Sample #502
 The AdroitLogic ToolBox