This documentation is for WSO2 Enterprise Integrator version 6.1.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

This section describes how to configure the JMS transport in WSO2 Enterprise Integrator (WSO2 EI) with ActiveMQ. The following topics are covered:

From the below configurations, do the ones in the axis2.xml file based on the profile you use as follows:

  • To enable the JMS transport in the Integration profile, edit the <EI_HOME>/conf/axis2/axis2.xml file.
  • To enable the JMS transport in other profiles, edit the <EI_HOME>/wso2/<PROFILE_HOME>/conf/axis2/axis2.xml file. <PROFILE_HOME> refers to the main directory of the profile inside the WSO2 EI distribution. For example, to enable the JMS transport in the Business Process profile, edit the <EI_HOME>/wso2/business-process/conf/axis2/axis2.xml file

Setting up WSO2 EI and ActiveMQ

Follow the instructions below to set up and configure.

  1. Download, set up and start Apache ActiveMQ.   
  2. Follow the Installation Guide and set up WSO2 EI.

    Do not start WSO2 EI at this point. ActiveMQ should be up and running before starting WSO2 EI.

  3.  Copy the following client libraries from the   <ACTIVEMQ_HOME>/lib directory  to the  < EI_HOME>/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 <ACTIVEMQ_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

  4. Next, configure JMS transport listeners and senders in WSO2 EI 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

    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&amp;jms.redeliveryPolicy.initialRedeliveryDelay=10000</parameter>

  5. Start ActiveMQ by navigating to <ACTIVEMQ_HOME>/bin folder and executing ./activemq console(on Linux/OSX) or activemq start(on Windows).

  6. Start WSO2 EI by navigating to <EI_HOME>/bin folder and executing ./integrator.sh(on Linux/OSX) or integrator.bat(on Windows).

    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 EI's JMS message store to work as expected.

    -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=“*"

    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:

    ERROR - JmsConsumer [JMS-C-1] cannot receive message from store. Error:Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class org.apache.synapse.message.store.impl.commons.StorableMessage! This class is not trusted to be serialized as ObjectMessage payload.

    Now you have instances of ActiveMQ and WSO2 EI 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 <EI_HOME>/conf/axis2/axis2.xml file.

<!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)-->
<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 <EI_HOME>/conf/axis2/axis2.xml file.

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
For details on the JMS configuration parameters used in the code segments above, see JMS Connection Factory Parameters.

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. WSO2 EI will not reconnect to ActiveMQ, instead it will throw some errors when requests are sent to WSO2 EI 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,

failover:tcp://localhost:61616

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    

WSO2 EI 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.

  1. Configure the WSO2 EI to work with one ActiveMQ broker as described above.
  2.  Start another ActiveMQ instance.
  3.  Add another transport receiver to the <EI_Home>/conf/axis2/axis2.xml file as follows. Note that the name of the transport receiver is different to that of the transport receiver already entered. The port specified is 61617.

    <transportReceiver name="jms1" 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:61617</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:61617</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:61617</parameter>
               <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
                <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
           </parameter>
       </transportReceiver>
  4. Set up the JMS sender as explained in Setting up the JMS sender.

Configuring Redelivery in ActiveMQ Queues

When WSO2 EI 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 WSO2 EI due to failures.  

  1. Enable the JMS listener as explained in Setting up the JMS listener.
  2. Add the following JMS parameters into the proxy service configuration in WSO2 EI:

    <parameter name="redeliveryPolicy.maximumRedeliveries">1</parameter>
    <parameter name="transport.jms.DestinationType">queue</parameter>
    <parameter name="transport.jms.SessionTransacted">true</parameter>
    <parameter name="transport.jms.Destination">JMStoHTTPStockQuoteProxy</parameter>
    <parameter name="redeliveryPolicy.redeliveryDelay">2000</parameter>
    <parameter name="transport.jms.CacheLevel">consumer</parameter>

    Parameters

    • 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 consumer for the ActiveMQ redelivery mechanism to work.
  3. Add the following line in your fault sequence:

    <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>

    SET_ROLLBACK_ONLY

    This parameter must be defined for ActiveMQ to redeliver the message.
    When WSO2 EI is unable to deliver a message to the back-end service due to an error, it will be routed to the fault sequence in WSO2 EI configuration. When "SET_ROLLBACK_ONLY" property is set in the fault sequence, WSO2 EI informs ActiveMQ to redeliver the message. 

        Below is a sample proxy service configuration:

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="JMStoHTTPStockQuoteProxy"
       transports="jms"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="transactionID"
                   expression="get-property('MessageID')"
                   scope="default"/>
         <property name="sourceMessageID"
                   expression="get-property('MessageID')"
                   scope="default"/>
         <property name="proxyMessageID"
                   expression="get-property('MessageID')"
                   scope="default"/>
         <log level="full">
            <property name="transactionID" expression="get-property('transactionID')"/>
            <property name="sourceMessageID" expression="get-property('sourceMessageID')"/>
            <property name="MessageID" expression="get-property('proxyMessageID')"/>
         </log>
         <property name="SET_ROLLBACK_ONLY" value="true" scope="axis2"/>
         <drop/>               
      </inSequence>
      <faultSequence="jms_fault">
   </target>
   <parameter name="redeliveryPolicy.maximumRedeliveries">1</parameter>
   <parameter name="transport.jms.DestinationType">queue</parameter>
   <parameter name="transport.jms.SessionTransacted">true</parameter>
   <parameter name="transport.jms.Destination">JMStoHTTPStockQuoteProxy</parameter>
   <parameter name="redeliveryPolicy.redeliveryDelay">2000</parameter>
   <parameter name="transport.jms.CacheLevel">consumer</parameter>
   <description/>
</proxy>
  • No labels