Tuesday, December 15, 2015

In this Post I'll explain you how to Send a message to a ESB proxy service, Store the message in a messaging queue and respond the client with a custom respone.

The message flow is depicted as below.

As per the above diagram, A request is sent to the ESB and ESB will send out the message to ActiveMQ as a OUT_ONLY message, where ESB will not expect a response from ActiveMQ, at the same time the ESB will send a response to the client.

To achieve this first you need to enable JMS transport senders and listeners in the ESB in-order to receive and send JMS messages. You can do this by following this.

After configuring the ESB create the following Proxy service. Now when you send a request to the following proxy it will send store a message in the JMS queue and send a response to the client.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
         <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
            <property name="==" value="============== In the In Sequence ================"/>
               <address uri="jms:/TESTQUEUE?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue"/>
         <payloadFactory media-type="xml">
               <Response xmlns="">CUSTOM RESPONSE!!!</Response>

In the above proxy please note the OUT_ONLY property which tells the ESB to send the message out and ignore any response.

Hope this post is useful to someone, Feel free to drop a comment if you have any queries. :)
Subscribe to RSS Feed Follow me on Twitter!