This section describes how to configure the WSO2 ESB's JMS transport with ActiveMQ. The following topics are covered:
Setting up WSO2 ESB and ActiveMQ
Follow the instructions below to set up and configure.
- Download, set up and start Apache ActiveMQ by navigating to
<ACTIVEMQ_HOME/bin>folder and executing
./activemq console(on Linux/OSX) or
activemq start(on Windows).
Follow the Installation Guide and set up WSO2 ESB.
ActiveMQ should be up and running before starting the ESB.
- Copy the following client libraries from the
<AMQ_HOME>/libdirectory to the
ActiveMQ 5.8.0 and above
- activeio-core-3.1.4.jar (available in
Earlier version of ActiveMQ
Next, configure JMS transport listeners and senders in ESB based on your requirement. When you need to listen to a JMS queue you need to configure the JMS transport listener and when you need to send messages to a JMS queue you need to configure the JMS transport sender.
Start ESB by navigating to
<ESB_HOME/bin>folder and executing
./wso2server.sh(on Linux/OSX) or
If you are using ActiveMQ 5.12.2 and above when working with message stores, you need to set the following system property on server start up for WSO2 ESB's JMS message store to work as expected.
Setting the above property is required because users are enforced to explicitly whitelist packages that can be exchanged using ObjectMessages with ActiveMQ 5.12.2 and above.
Therefore, if the above property is not set, the message processor fails to read messages from ActiveMQ with the following error:
Now you have instances of ActiveMQ and WSO2 ESB configured, up and running. Next, let's take a look at implementation details of various JMS use cases.
Setting up the JMS listener
To enable the JMS transport listener, un-comment the following listener configuration related to ActiveMQ in
Setting up the JMS sender
To enable the JMS transport sender, un-comment the following configuration in
The above configurations do not address the problem of transient failures of ActiveMQ message broker. Let's say for some reason ActiveMQ goes down and comes back up after a while. ESB will not reconnect to ActiveMQ, instead it will throw some errors when requests are sent to ESB until it is restarted. In order to tackle this issue one needs to add the following configuration in the place of the java.naming.provider.url,
This will simply make sure re-connection takes place. Failover prefix is associated with the Failover Transport of ActiveMQ. For further information about this please try The Failover Transport.
Connecting multiple ActiveMQ brokers
The WSO2 ESB can be configured as explained in the following section to work with two ActiveMQ brokers. In this example, port 61616 is used for one ActiveMQ instance and port 61617 is used for the other ActiveMQ instance.
- Configure the ESB to work with one ActiveMQ broker as described above.
- Start another ActiveMQ instance.
Add another transport receiver to the
<ESB_Home>/repository/conf/axis2/axis2.xmlfile as follows. Note that the name of the transport receiver is different to that of the transport receiver already entered. The port specified is
- Set up the JMS sender as explained in Setting up the JMS sender.
Configuring Redelivery in ActiveMQ Queues
When WSO2 ESB is configured to consume messages from an ActiveMQ queue, you have the option to configure message re-delivery. This is useful when messages are unable to be processed by ESB due to failures.
- Enable the JMS listener as explained in Setting up the JMS listener.
Add the following JMS parameters into the proxy service configuration in WSO2 ESB:
redeliveryPolicy.maximumRedeliveries: Maximum number of retries for delivering the message. If set to -1 ActiveMQ will retry inifinitely.
transport.jms.SessionTransacted: When set to
true, this enables the JMS session transaction for the proxy service.
redeliveryPolicy.redeliveryDelay: Delay time in milliseconds between retries.
transport.jms.CacheLevel: This needs to be set to
consumerfor the ActiveMQ redelivery mechanism to work.
Add the following line in your fault sequence:
<property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
SET_ROLLBACK_ONLYThis parameter must be defined for ActiveMQ to redeliver the message.When ESB is unable to deliver a message to the back-end service due to an error, it will be routed to the fault sequence in the ESB configuration. When "SET_ROLLBACK_ONLY" property is set in the fault sequence, ESB informs ActiveMQ to redeliver the message.
Below is a sample proxy service configuration: