Configuring the JMS Inbound Protocol with ActiveMQ
This section describes how to configure WSO2 ESB JMS inbound protocol with ActiveMQ.
Follow the instructions below to set up and configure Apache ActiveMQ as the JMS server:
- Download and set up Apache ActiveMQ. For more information, see Installation Prerequisites
Set up WSO2 ESB. For information on getting the ESB set up, see Installation Guide.
Note
ActiveMQ should be up andrunningbefore starting the ESB.
- Copy the following client libraries from the
<AMQ_HOME>/lib
directory to the< ESB_HOME>/repository/components/lib
directory.ActiveMQ 5.8.0 and above
- activemq-broker-5.8.0.jar
- activemq-client-5.8.0.jar
- activemq-kahadb-store-5.8.0.jar
- geronimo-jms_1.1_spec-1.1.1.jar
- geronimo-j2ee-management_1.1_spec-1.0.1.jar
- geronimo-jta_1.0.1B_spec-1.0.1.jar
- hawtbuf-1.9.jar
- Slf4j-api-1.6.6.jar
- activeio-core-3.1.4.jar (available in
<AMQ_HOME>/lib/optional
folder)
Earlier version of ActiveMQ
activemq-core-5.5.1.jar
geronimo-j2ee-management_1.0_spec-1.0.jar
geronimo-jms_1.1_spec-1.1.1.jar
- Next, configure the inbound listener in the ESB.
Configuring the JMS inbound listener
Following is a sample JMS inbound listener configuration:
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="jms" sequence="request" onError="fault" protocol="jms" suspend="false"> <parameters> <parameter name="interval">1000</parameter> <parameter name="transport.jms.Destination">ordersQueue</parameter> <parameter name="transport.jms.CacheLevel">1</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter> <parameter name="sequential">true</parameter> <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter> <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter> <parameter name="transport.jms.SessionAcknowledgement">AUTO_ACKNOWLEDGE</parameter> <parameter name="transport.jms.SessionTransacted">false</parameter> <parameter name="transport.jms.ConnectionFactoryType">queue</parameter> </parameters> </inboundEndpoint>
Note
The sample configuration above does not address the problem of transient failures of the ActiveMQ message broker. For example, if we consider a scenario where the ActiveMQ broker goes down for some reason and comes back up after a while. The ESB will not reconnect to ActiveMQ but instead it will throw errors when requests are sent to the ESB until it is restarted.
In order to tackle this issue you need to specify the following as the java.naming.provider.url
parameter value.
failover:tcp://localhost:61616
Setting this as the value for the java.naming.provider.url
parameter will make sure that re-connection takes place when ActiveMQ is up and running. The failover prefix is associated with the failover transport of ActiveMQ. For more information, see Failover Transport.
Now you have an instances of ActiveMQ and WSO2 ESB inbound endpoint configured, up and running.