Over a million developers have joined DZone.
Platinum Partner

JMS-source -> ESB-Processing -> JMS-destination

The Integration Zone is brought to you in partnership with 3scale. Take control of your APIs and get a free t-shirt when you complete the 3step Challenge

Recently I prepared a demo and thought it might be useful if I share it in my blog.  If you are new to WSO2 ESB, it is recommended to refer the following prior posts.

Webinar : A Buyers Guide to an Enterprise Service Bus (ESB)
http://www.youtube.com/watch?v=yokfudCDcg8

How to write a proxy to filter soap 1.1 requests with WSO2 ESB http://achala11.blogspot.com/2011/12/how-to-write-proxy-to-filter-soap-11.html

 Proxy Services with WSO2 ESB / Monitoring with TCPMon
http://achala11.blogspot.com/2012/05/proxy-services-with-wso2-esb-monitoring.html

WSO2 ESB Proxy Services with Custom URLs
http://achala11.blogspot.com/2012/07/wso2-esb-proxy-services-with-custom.html

Route to an endpoint based on the time of the day - Using ESB
http://achala11.blogspot.com/2012/07/route-to-endpoint-based-on-time-of-day.html

Route messages based on HTTP Headers with WSO2 ESB
http://achala11.blogspot.com/2012/08/route-messages-based-on-http-headers.html


Ok, Let's look in to the demo.

Following are required for this.

WSO2 ESB - http://wso2.com/products/enterprise-service-bus/
activemq -
soapui -


Prerequisites
  • Download, install and start a JMS server.
  • Configure sample Axis2 server for JMS.
  • Start the Axis2 server and deploy the SimpleStockQuoteService.
  • Configure the Synase JMS transport.


Create the following proxy (StockQuoteProxy) in WSO2 ESB. This will store the message in a queue
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true"/>
         <log level="custom">
            <property name="1st proxy" value="-------------"/>
         </log>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="jms:/StockQuoteJmsProxy?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616"/>
      </endpoint>
   </target>
   <description></description>
</proxy>

Next lets create the second proxy. This will send the message to the jms destination (StockQuoteJmsProxy2).

<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteJmsProxy" transports="jms" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true"/>
         <log level="full">
            <property name="2nd proxy before" value="-------------"/>
         </log>
         <xslt key="xslt-key-req"/>
         <log level="full">
            <property name="2nd proxy after" value="-------------"/>
         </log>
      </inSequence>
      <outSequence>
         <log level="full">
            <property name="2nd proxy outttttttt" value="-------------"/>
         </log>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="jms:/StockQuoteJmsProxy2?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616"/>
      </endpoint>
   </target>
   <description></description>
</proxy>

Use soapui and create anew project using the wsdl of simple stock quote proxy. Read [1] post for more details.

When your check the queue "StockQuoteJmsProxy2" in activemq , you will be able to see the  new message.

[1] http://docs.wso2.org/wiki/display/ESB450/Sample+251%3A+Switching+from+HTTP(S)+to+JMS

The Integration Zone is brought to you in partnership with 3scale. Learn how API providers have changed the way we think about integration in The Platform Vision of API Giants.

Topics:

Published at DZone with permission of Achala Chathuranga Aponso , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}