This section explains, through an example scenario, how the Message Broker EIP can be implemented using WSO2 ESB. The following topics are covered:
Table of Contents | ||
---|---|---|
|
...
Setting up WSO2 Message Broker
- Download a binary version of WSO2 Start Message Broker from http://wso2.com/products/message-broker, and extract the distribution, which will be referred to as
<MB_HOME>
. Open
<MB_HOME>/repository/conf/carbon.xml
file, and change the offset of ports to 1. This is done to ensure that there will be no port conflicts when you run multiple WSO2 products simultaneously on the same server.Code Block <Ports> <Offset>1</Offset> ...
If you are using WSO2 MB version 2.0.0 or 2.1.0 , change the default virtual host to carbon in
<MB_HOME>/repository/conf/advanced/qpid-virtualhosts.xml
file.Code Block <virtualhosts> <default>carbon</default> ...
- Start WSO2 MB server by executing
wso2server.sh
(orwso2server.bat
in Windows) file in the<MB_HOME>/bin
directory.profile by executing the following script: <EI_HOME>/wso2/broker/bin/wso2server.sh
Setting up WSO2 ESB
- Download and install WSO2 ESB from http://wso2.com/products/enterprise-service-bus . Installation home will be referred to as
<ESB_HOME>
. For a list of prerequisites and step-by-step installation instructions, refer to Installation Guide in the WSO2 ESB documentation. - Copy the following files from <MB
<EI_HOME>/broker/client-lib
to <ESB<EI_
HOME>HOME>/repository/components/lib
.geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
andes-client-0.13.wso2v8.1.jar
Enable the JMS transport receivers and senders by uncommenting the relevant sections in the <ESB
<ESB_
HOME>HOME>/repository/conf/axis2/axis2.xml
file. For example:Code Block language html/xml <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> <parameter name="myTopicConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter> </parameter> <parameter name="myQueueConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> <parameter name="default" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">repository/conf/jndi.properties</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> </transportReceiver> ......... <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
Define the following properties in the
<ESB_HOME>/repository/conf/jndi.properties
file.Code Block language html/xml ..... #Need change QueueConnection factory as follows connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673' connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5673' # register some queues in JNDI using the form # queue.[jndiName] = [physicalName] queue.myqueue=myqueue # register some topics in JNDI using the form - Commented since this sample is not going to use Topics # topic.[jndiName] = [physicalName] #topic.MyTopic = example.MyTopic
- Start the sample Axis2 server on ports 9001 and 9002. For instructions, refer to the section Setting up the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation.
...
Simulating the sample scenario
Send a request using Stock Quote client to the proxy service in the following manner. For information on the Stock Quote client, refer to the Sample Clients section in WSO2 ESB documentation.
ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=WSO2
Note that the request is stored in WSO2 Message Broker. Any consumer can access the stored message by accessing destinationMyQueue
in WSO2 Message Broker.
How the implementation works
...
- jms:/myqueue - Looks for a JNDI entry
myqueue
(see JNDI properties above). - ? - Separator indicating extra attributes.
- transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory - Looks up
ConnectionFactory
in JNDI with nameQueueConnectionFactory
. - & - Separator (this will convert to ‘&’)
- java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory - Uses the andes properties-based JNDI.
- & - Another separator (this will convert to ‘&’)
- java.naming.provider.url=repository/conf/jndi.properties - Looks in
repository/conf/jndi.properties
for the JNDI properties file.