A message store is a storage in the ESB Profile of WSO2 Enterprise Integrator (WSO2 EI) for messages. The ESB profile of WSO2 EI ships with the following message store implementations: In Memory Message Store, JMS Message Store, RabbitMQ Message Store, JDBC Message Store. You also have the option to create a Custom Message Store with your own message store implementation.
For more information, see Message Stores . Next, let's take a look at a few business use case scenarios of JMS message stores.
Use case scenario 1
In this sample:
- The client sends requests to a proxy service.
- The proxy service stores the messages in a JMS message store.
- The back-end service is invoked by a message forwarding processor, which picks stored messages from the JMS message store.
Let's proceed to configure the sample scenario.
Configuring the message store
Create a JMS message store for the broker. Given below are the sample configurations for the WSO2 Message Broker profile and ActiveMQ broker.
Set the value of the <
java.naming.provider.url> property to point to the provider URL.
Set the value of the the <
java.naming.provider.url> property to point to the
jndi.properties file. In this case, <
store.jms.destination> is a mandatory parameter. If you are using the Message Broker Profile of WSO2 EI, you need to create a queue named 'JMSMS' using the Message Broker Profile (i.e., the value you specify for the
store.jms.destination parameter). For instructions on creating the queue, see Managing Queues.
Configuring the proxy service
Define an endpoint which is used to send the message to the back-end service.
Create a proxy service which stores messages to the created Message Store.
Note that you can use the FORCE_SC_ACCEPTED property in the message flow to send an Http 202 status to the client after the ESB accepts a message. If this property is not specified, the client that sends the request to the proxy service will timeout since it is not getting any response back from the proxy.
Configuring the message processor
Create a message forwarding processor using the below configuration. Message forwarding processor consumes the messages stored in the message store.
Testing the use case
Before you begin:
- Configure the ESB profile: Enable the JMS transport (for your JMS broker) in the ESB profile. See Configure with the Message Broker Profile or Configure with ActiveMQ for instructions if you are using the MB profile or ActiveMQ.
- Set up the back-end service: Deploy the SimpleStockQuoteService service in the axis2 server that is shipped with WSO2 EI, and then start the axis2 server. See the instructions in Setting Up the ESB Samples. The back-end service is now started!
To invoke the proxy service, we use the sample axis2 client shipped with WSO2 EI. Navigate to
<EI_HOME>/samples/axis2client directory, and execute the following command to invoke the proxy service.
Note a message similar to the following example printed in the Axis2 Server console.
Use case scenario 2
In the sample, when the message forwarding processor receives a response from the back-end service, it forwards it to a replySequence to process the response message.
Let's proceed to configuring this sample scenario.
Configure the broker
1. See Configure with the Message Broker Profile or Configure with ActiveMQ for details on setting up a broker server for this sample. Note that you only need to set up the broker server itself and do not need to configure the listeners and senders in the configuration (i.e., just perform steps 1 through 4 in the Message Broker instructions or 1 through 3 in the ActiveMQ instructions).
2. Create a JMS message store for the broker set up in step 1. To create proxy services, sequences, endpoints, message stores and processors, you can either use the management console or copy the XML configuration to the source view. You can find the source view under menu Manage > Service Bus > Source View in the left navigation pane of the Integration Profile management console. Alternatively, you can add an XML file to
If you use ActiveMQ, the sample message store configuration is as follows:
Set the value of the the <
java.naming.provider.url>property to point to the provider URL.
If you use WSO2 Message Broker as the broker server, the sample message store configuration is as follows:
Set the value of the the <
java.naming.provider.url>property to point to the
jndi.propertiesfile. In this case, <
store.jms.destination>is a mandatory parameter.
Configuring the back-end service
1. Set up the prerequisites given in the Prerequisites section in Setting Up the ESB Samples. Then, deploy the SimpleStockQuoteService client by navigating to
EI_HOME>/samples/axis2Server/src/SimpleStockQuoteService, and run the ant command in the command prompt or shell script. This will build the sample and deploy the service for you.
2. WSO2 EI comes with a default Axis2 server, which you can use as the back-end service for this sample. To start the Axis2 server, navigate to
<EI_HOME>/samples/axis2server and run
axis2Server.sh (on Linux) or
axis2Server.bat (on Windows).
3. Point your browser to http://localhost:9000/services/SimpleStockQuoteService?wsdl and verify that the service is running.
You now have a JMS message store configured. Next, configure the Integration Profile of WSO2 EI for the specific message broker you use.
Configuring the ESB Profile of WSO2 EI
1. Define an endpoint, which is used to send the message to the back-end service.
2. Create a proxy service which stores messages to the created Message Store.
3. Create a sequence to handle the response received from the back-end service.
4. Create a message forwarding processor using the below configuration. Message forwarding processor consumes the messages stored in the message store. Compared to the message processor in sample 1 , this has an additional parameter message.processor.reply.sequence to point to a sequence to handle the response message.
Once the back-end service and the Integration Profile of WSO2 EI are configured, proceed to invoking the sample as follows.
Executing the sample
1. To invoke the proxy service, we use the sample axis2 client shipped with WSO2 EI. Navigate to
<EI_HOME>/samples/axis2client/ directory, and execute the following command to invoke the proxy service.
2. Note the service being invoked and then the response being logged from the replySequence. For example,