Configuring WSO2 ESB 4.5.1 with WSO2 MB 2.0.1 For Message Stores


This guide is to configure WSO2 Message Broker 2.0.1 with WSO2 ESB 4.5.1 locally. WSO2 MB is configured to use inbuilt Cassandra Database in this example, and only one MB instance will be used (of course you can cluster it).

Configurations for Message Broker

1.       Unzip WSO2 MB 2.0.1 pack. You can download it form here
2.       We will start WSO2 MB with a port offset of 1. For that open /repository/conf/carbon.xml file and define offset.
    <Ports>
           <!-- Ports offset. This entry will set the value of the ports defined below to
            the define value + Offset.
            e.g. Offset=2 and HTTPS port=9443 will set the effective HTTPS port to 9445
            -->
           <Offset>1</Offset>
    

3.        To start it with one node, we will use internal Cassandra bundled with WSO2 MB. As we have   all port off-set by 1, we will have to point MB to correct Cassandra port. Go to /repository/conf/advanced/qpid-virtualhosts.xml and edit it to the correct port.
    <carbon>
             <store>               
             <class>org.wso2.andes.server.store.CassandraMessageStore</class>
                   <username>admin</username>
                   <password>admin</password>
                   <cluster>ClusterOne</cluster>               
     <idGenerator>org.wso2.andes.server.cluster.coordination.TimeStampBasedMessageI     dGenerator</idGenerator>
                   <connectionString>localhost:9161</connectionString>
               </store>
    
            Note: if you are using an external Cassandra instance you can point MB to it editing the              connection string.
4.        Whenever subscriptions are made or removed for queues, info level logs are printed. But when using MB 2.0.1 with Message processors it is always peeking for messages triggering subscription logs.  To stop that edit log4j.properties file available at /repository/conf/log4j.properties file with the following line
    #andes specific
    log4j.logger.org.wso2.andes.server.cassandra.DefaultClusteringEnabledSubscriptionManager=WARN 
    

5.       Now navigate to /bin and run wso2server.bat file, and start WSO2 MB.


Configurations for WSO2 ESB


Unzip WSO2 ESB 4.5.1 pack. You can download it form here


1.       Unzip WSO2 ESB 4.5.1 pack. You can download it form here
2.       To setup backend (for demonstration of this example.)
                 2.1     Navigate to /samples/axis2Server/src/SimpleStockQuoteService and run ‘ant’ to build.
                 2.2     Come back to /samples/axis2Server folder and run axis2Server.bat file.
                 2.3      Point your browser to http://127.0.0.1:9000/services/SimpleStockQuoteService?wsdl and verify that the service is running.
3.       Open JNDI.proerties file in /repository/conf folder and point to the MB broker being run. Also use ‘carbon’ as the virtualhost. Define a queue called ‘JMSMS’ there. No need of a topic here, so comment it out.
    # register some connection factories
    
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673'
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.JMSMS=JMSMS
4.       Start WSO2 ESB by running /bin/wso2Server.bat file.
5.       Define a message Store by copy-pasting following config to the source view (Alternatively you can use message-store UI).
     <messageStore class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
                    name="JMSMS">
         <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
         <parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>
         <parameter name="store.jms.destination">JMSMS</parameter>
      </messageStore>
6.        Define an end-point to send the message. In this example we use above backend we just set-up.
      <endpoint name="SimpleStockQuoteService">
         <address uri="http://127.0.0.1:9000/services/SimpleStockQuoteService"/>
      </endpoint>
    
     
           

7.         Define a message forwarding processor as below (by copy-pasting or using the Management Console UI).
      <messageProcessor class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
                        name="Processor1"
                        messageStore="JMSMS">
         <parameter name="max.delivery.attempts">4</parameter>
         <parameter name="interval">4000</parameter>
      </messageProcessor>
    



Proxy Service for WSO2 ESB to Test Setup

Now to test the scenario use a proxy service like below.
  <proxy name="InOnlyProxy"

         transports="https http"
         startOnLoad="true"
         trace="disable">
     <target>
        <inSequence>
           <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
           <property name="OUT_ONLY" value="true"/>
           <property name="target.endpoint" value="SimpleStockQuoteService"/>
           <log level="full"/>
           <store messageStore="JMSMS"/>
        </inSequence>
     </target>
  </proxy>
 


Note the highlighted parts, which are related.
Now whenever a message comes to this proxy service, it will be stored in JMS message store (which is in MB, JMSMS queue. If you disable message processor and send messages you will notice in MB management console message count of JMSMS queue being increased.)

This is “In Only” service invocation with Message Forwarding Processor. Similarly, following this article  you can implement the others. 


To Test 

With soap UI send the following soap message to the InOnlyProxy. 
<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:getQuote>
        <!--Optional:-->
        <ser:request>
           <!--Optional:-->
           <xsd:symbol>IBM</xsd:symbol>
        </ser:request>
     </ser:getQuote>
  </soapenv:Body>
</soapenv:Envelope>



Message will be logged at ESB console, SOAP UI will get 202 Accepted message, and at axis2Server console following will be logged.

samples.services.SimpleStockQuoteService :: Generating quote for : IBM


Hasitha Hiranya

2 comments:

  1. Hi,

    I followed the steps but my esb starts at port 8243

    It throws error "Can not create the event broker "

    I had posted problem here also, and you might know it,
    http://buddhimawijeweera.wordpress.com/2012/10/27/connect-wso2-esb-with-wso2-mb/

    please help me in this regard.

    Thanks and Regards,
    Naveen

    ReplyDelete
  2. Hi,

    port 8243 is from axis2.xml in \repository\conf\axis2.

    do we have to change anything in event-broker.xml at \repository\conf

    My esb isnt running...

    Thanks and Regards.

    ReplyDelete

Instagram