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.
2. We will start WSO2 MB with a port offset of 1. For that open
<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
5. Now navigate to /bin and run wso2server.bat file, and start WSO2 MB.
/samples/axis2Server/src/SimpleStockQuoteService and run ‘ant’ to build.
/samples/axis2Server folder and run axis2Server.bat file.
/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.
#andes specific log4j.logger.org.wso2.andes.server.cassandra.DefaultClusteringEnabledSubscriptionManager=WARN
Configurations for WSO2 ESB
Unzip WSO2 ESB 4.5.1 pack. You can download it form here.
# 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).
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.
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