This section describes how to integrate WSO2 Message Broker with WSO2 Enterprise Service Bus to facilitate message brokering needs of the ESB and to implement store and forward messaging pattern.
The first step is to set up WSO2 MB and WSO2 ESB.
Setting up WSO2 Message Broker
Stratos Message Broker - Dashboard UI Features.
- Download and install WSO2 MB according to the instructions in Installation Guide.
It is not possible to start multiple WSO2 products with their default configurations simultaneously in the same environment. Since all WSO2 products use the same port in their default configuration, there will be port conflicts. Therefore, to avoid port conflicts, apply a port offset in the
<MB_HOME>/repository/conf/carbon.xmlfile by changing the offset value to 1. For example,
- Start the Message Broker by running
<MB_HOME>/bin/wso2server.sh(on Linux) or
Setting up WSO2 ESB
- Download and install WSO2 ESB according to the instructions in Getting Started. The unzipped ESB distribution folder is referred to as
Enable the JMS transport of WSO2 ESB to communicate with the Message Broker by editing the
<ESB_HOME>/repository/conf/axis2/axis2.xmlfile. Find a commented
<transport receiver>block for MB and uncomment it as shown below.
Also, uncomment the
<transport sender>block for JMS in the same file as shown below.
- Copy the following jar files from the
<MB_HOME>/clent-libfolder to the
- Open the
JNDI.proertiesfile and make a reference to the running Message Broker as shown below.
carbonas the virtualhost. Define a queue called
JMSMS. Comment out the topic since it is not needed for this scenario. However, in order to avoid getting the
javax.naming.NameNotFoundException: TopicConnectionFactoryexception during server startup, make a reference to the Message Broker from the
The connection factory specifies the URL to be used by a client using WSO2 MB in order to connect to it. 5673 in this example is the port listening for messages on TCP when the AMQP transport is used. This port changes depending on the port offsets done in different scenarios. See Configuring a Client to Access Broker When Port Offset is Change for more information.
If you want to create a queue that is specific to a particular tenant (e.g., a tenant with
test.comdomain), the following is required.
- The connection factory entries should have the tenant's credentials instead of the super tenant's credentials.
- The queue name should have the tenant's domain as a prefix as shown below.
See Managing Tenant-specific Subscriptions for detailed information.
- Start WSO2 ESB by running
<ESB_HOME>/bin/wso2server.sh(on Linux) or
Now you will have both the Enterprise Service Bus and the Message Broker running.
- We need some background services to be available for testing purposes. Therefore, run an ANT task to deploy the
SimpleStockQuoteServicein the simple axis2server as follows.
- Navigate to
<ESB_HOME>/samples/axis2Server/src/SimpleStockQuoteServiceand run the
antcommand to build the sample and deploy background services.
- Next, run
<ESB_HOME>/samples/axis2server/axis2Server.sh(on Linux) to start the Axis2 server.
http://127.0.0.1:9000/services/SimpleStockQuoteService?wsdlin the address bar of your browser and press the Enter key to verify that the service is running.
- Navigate to
You now have two instances of WSO2 Message Broker and WSO2 ESB configured, up and running. Next, proceed to integrate the Message Broker with ESB, for which there are two implementation options as follows.
Integration Using JMS Endpoints and JMS Proxy Services
This section describes how to integrate WSO2 Message Broker with WSO2 ESB as JMS endpoints. A user case is used for this purpose.
Store a message received to a http proxy of the ESB in a JMS queue. Then consume that queue, get the message and send it to the actual endpoint.
Create a JMS proxy named
StockQuotesQueue. It is the same name defined in the jndi.properties file above. By creating this proxy, you will be creating a consumer to make a subscription to be used in this user case. The Synapse configuration of the proxy looks as follows. See Adding a Proxy Service for detailed instructions to create a proxy service.
Once this proxy service is configured, the
StockQuotesQueueJMS queue will be created in the MB management console (see Browsing Queues for more information).
Create the HTTP proxy to send messages to the JMS Queue. Synapse configuration of this HTTP proxy is as follows. Since this is a one-way message, the
OUT_ONLYproperty is set to
FORCE_SC_ACCEPTEDproperty is defined to send a 202 response to the client that invokes this proxy.
The message flow paths are completed. When the
StockQuoteProxyproxy service is invoked, it will send the message to the queue. This message will be consumed by the
StockQuotesQueueJMS proxy and sent to the actual endpoint.
Testing the Integration
Send the following SOAP message to
StockQuoteProxy proxy service using the SOAP UI.
The above message will be logged in the ESB console as output.
The log of the SimpleAxis2Server will be as follows.
Integrate Using Message Stores and Processors
This section describes how to integrate WSO2 Message Broker with WSO2 ESB using message stores and processors.
Perform the following steps in WSO2 ESB.
Create a message store with the following configuration. See Adding a Message Store for further information.
Define an endpoint to send the message. In this example, the backend just set-up in the previous step is used.
Define a message forwarding processor with the following configuration. See Adding a Message Processor for further information.
Define a proxy service with the following configuration.
Messages sent to this proxy service are stored in the
JMSMSqueue in the Message Broker which serves as a message store.I If messages are sent while the message processor is disabled, you will notice an increase in the message count of the
JMSMSqueue in the MB Management Console. See Browsing Queues for more information.
Testing the Integration
Using the SOAP UI, send the following SOAP message to the
InOnlyProxy proxy service you created.
The above message will be logged in ESB console. SOAP UI will get the
202 Accepted message.
The following message will be logged in the axis2server console.
To adapt to your specific environment, simply replace the following with a suitable name.