This section describes how to configure the WSO2 ESB's JMS transport with ActiveMQ 5.5.1. Follow the instructions below to set up and configure.
1. Download and set up Apache ActiveMQ. Instructions can be found in section Installation Prerequisites.
2. Follow the Getting Started and set up WSO2 ESB.
ActiveMQ should be up and running before starting the ESB.
3. Copy the following client libraries from <AMQ_HOME>/lib directory to <ESB_HOME>/repository/components/lib directory.
activemq-core-5.5.1.jar (in ActiveMQ version 5.8.0 and above, activemq-core-5.5.1.jar has been split into activemq-broker-5.8.0.jar and activemq-client-5.8.0.jar)
geronimo-j2ee-management_1.0_spec-1.0.jar
geronimo-jms_1.1_spec-1.1.1.jar
- If you are using ActiveMQ version 5.8.0 or later, copy hawtbuf-1.2.jar to <ESB_HOME>/repository/components/lib directory.
4. Next, configure transport listeners and senders in ESB.
When configuring JMS with ActiveMQ, you can append ActiveMQ-specific properties to the value of the java.naming.provider.url
property. For example, you can set the redeliveryDelay
and initialRedeliveryDelay
properties when configuring a JMS inbound endpoint as follows:
<parameter name="java.naming.provider.url">tcp://localhost:61616?jms.redeliveryPolicy.redeliveryDelay=10000&jms.redeliveryPolicy.initialRedeliveryDelay=10000</parameter>
Setting up the JMS Listener
To enable the JMS transport listener, un-comment the following listener configuration related to ActiveMQ in <ESB_HOME>/repository/conf/axis2/axis2.xml file.
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> <parameter name="myTopicConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</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.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</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.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> </transportReceiver>
Setting up the JMS Sender
To enable the JMS transport sender, un-comment the following configuration in <ESB_HOME>/repository/conf/axis2/axis2.xml file.
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
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 won't reconnect to ActiveMQ but instead it'll throw some errors as requests are sent to ESB till 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,
failover:tcp://localhost:61616
This will simply make sure re-connection takes place when ActiveMQ is up and running. Failover prefix is associated with the Failover Transport of ActiveMQ. For further information about this please try The Failover Transport.
You now have instances of ActiveMQ and WSO2 ESB configured, up and running. Next, refer to section JMS Usecases for implementation details of various JMS use cases.