Thursday, April 25, 2013

JMS Proxy service using WSO2 ESB



WSO2 ESB is capable to communicate with JMS transport as well. In this blog post you can see how to configure a proxy service with JMS transport.

Please refer  How to enable ESB for JMS transport for ESB server configuration to work with ActiveMQ JMS Broker.

Bellow proxy service is expose via jms transport by defining the transports="jms". so deploy the proxy service in WSO2  ESB

 <proxy name="JmsProxy" transports="jms" startOnLoad="true" trace="disable">
        <target>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
            <inSequence>
                <property name="OUT_ONLY" value="true"/>
                <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
                <header name="Action" value="urn:placeOrder"/>
            </inSequence>
        </target>
        <parameter name="transport.jms.ContentType">
            <rules>
                <jmsProperty>contentType</jmsProperty>
                <default>text/xml</default>
            </rules>
        </parameter>
 </proxy>  

Once you deploy the above proxy service, you can see a queue named jmsProxy is created in JMS broker. then the proxy service is listening to the  jmsProxy queue. whatever a message is put into that queue, the proxy service pick the message from the queue and send it to the endpoint definded in the proxy service. as this proxy service message is route to the SimpleStockQuoteService.

if you want to test this proxy service, you can put a soap message in to the jmsProxy queue using a JMS client or you can create another http proxy service to put a message to the jmsProxy queue.

Bellow proxy service configuration is a http proxy service which route a incomming message to jms queue.

<proxy name="StockQuoteProxyToJMSQueue" transports="http" startOnLoad="true" trace="disable">  
     <description/>  
     <target>  
       <inSequence>  
         <property name="OUT_ONLY" value="true"/>  
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>  
         <send>  
           <endpoint>  
             <address  
                 uri="jms:/jmsProxy?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://127.0.0.1:61616&amp;transport.jms.DestinationType=queue"/>  
           </endpoint>  
         </send>  
       </inSequence>  
     </target>  
   </proxy>  

 then you can send to soap message to StockQuoteProxyToJMSQueue proxy service. then it will put your message to jmsProxy queue. so jmsProxy service pick the message form the queue and send it the actual back end service running on a axis2 server.

 you can use soapui to send the message to http proxy

http://localhost:8282/services/StockQuoteProxyToJMSQueue

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">  
   <soapenv:Header/>  
   <soapenv:Body>  
    <ser:placeOrder>   
      <ser:order>   
       <xsd:price>20</xsd:price>    
       <xsd:quantity>1000</xsd:quantity>  
       <xsd:symbol>WSO2</xsd:symbol>  
      </ser:order>  
    </ser:placeOrder>  
   </soapenv:Body>  
 </soapenv:Envelope>  







3 comments:

  1. Hello sir. i have read so many blog on this same topic. but yours is little different, with easily understandable lines. I have a same blog on this same topic also. You can check mine. You can suggest me if any changes required. Visit us : https://www.proxyrotator.com/contact-us/

    ReplyDelete
  2. I have gone through your entire blog. When I started to read it, I just went on and on. Wonderful blog. I love this. Thanks. Hopefully, you keep on producing more such blogs https://www.proxyrotator.com/

    ReplyDelete