Showing posts with label WSO2MB. Show all posts
Showing posts with label WSO2MB. Show all posts

Friday, July 25, 2014

Without restart: Enabling WSO2 ESB as a JMS Consumer of WSO2 MB

WSO2 ESB 4.8.1 & WSO2 MB 2.2.0 documentations have information on how to configure WSO2 ESB as a JMS Consumer of WSO2 MB queues and topics. But they do not point out a way to do this without restarting ESB server.

In this blog post we'll solve this issue.

With this method we will be able to create new queues in WSO2 MB and consume them from WSO2 ESB without restarting it.

Configure the WSO2 Message Broker

  • Offset the port of WSO2 MB to '1'  
  • Copy andes-client-*.jar and geronimo-jms_1.1_spec-*.jar from $MB_HOME/client-lib to $ESB_HOME/repository/components/lib 
  • Start the WSO2 MB

Configure the WSO2 Enterprise Service Bus

  • Edit the $ESB_HOME/repository/conf/jndi.properties file (comment or delete any existing configuration)
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673'
connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673'
  • Edit the $ESB_HOME/repository/conf/axis2.xml file and uncomment the JMS Sender and JMS Listener configuration for WSO2 Message Broker 
  • Start the WSO2 ESB 

Create Proxy Service

The Proxy Service name will become the queue name in WSO2 MB. If you already have a queue in MB and if you want to listen to that queue, then set that queue name as the proxy service name. Here I'm using 'JMSConsumerProxy' as the queue name and the proxy service name.

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
       name="JMSConsumerProxy" 
       transports="jms" 
       statistics="disable" 
       trace="disable" 
       startOnLoad="true"> 
   <target> 
      <inSequence> 
         <property name="Action" 
                   value="urn:placeOrder" 
                   scope="default" 
                   type="STRING"/> 
         <log level="full"/> 
         <send> 
            <endpoint> 
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
            </endpoint> 
         </send> 
      </inSequence> 
      <outSequence> 
         <drop/> 
      </outSequence> 
   </target> 
   <description/> 
</proxy> 

Testing the scenario

  • Inside $ESB_HOME/samples/axis2Server/src/SimpleStockQuoteService run ant 
  • Now start the Axis2 Server inside $ESB_HOME/samples/axis2Server (run the relevant command line script
  • Log into the WSO2 Message Broker Management Console and navigate to Browse Queues 
  • Find a Queue by the name JMSConsumerProxy 
  • Publish 1 message to the JMSConsumerProxy with payload (this has to be done in the Message Broker Management Console) 
<ser:placeOrder xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd"> 
    <ser:order> 
        <xsd:quantity>4</xsd:quantity> 
    </ser:order> 
</ser:placeOrder>
  • Observe the output on the Axis2 Server and WSO2 ESB console.
Hope this helped you :)