Sunday, November 4, 2012

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

Recently , i prepared a demo and thought it might be useful if i share in my blog.

If you are new to WSO2 ESB, it is recommended to refer the following , prior to this post.

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










No comments:

Post a Comment