Saturday, December 5, 2015

How to disable JMS transport for ESB manager node in Cluster environment - ESB 4.9.0

Environment 

WSO2 ESB 4.9.0 Cluster Setup (Manager  and Worker Pattern)


Description

After creating the cluster  setup in ManagerWorker Pattern, You may require  to keep Manager node only for the deployments and configurations. (Where you don't need to process JMS messages inside the Manager node)

Solution 

You can find a new feature called “JMS inbound endpoints” with the ESB 4.9.0 which can use to handle this kind of scenarios.

Firstly, you have to follow ESB 4.9.0 clustering document [1] and check whether your cluster is in the Manager - Worker pattern. The main difference in the configuration of Manager and Worker is followed.

IN AXIS2.XML
The manager should have the parameter
<property name="subDomain" value="mgt"/>

Worker Should have the parameter
<property name="subDomain" value="worker"/>

IN CARBON.XML
The manager should have configured with both AutoCommit = true and AutoCheckout = true
The worker should have configured with AutoCommit = false and AutoCheckout = false

After confirming the Manager-Worker pattern we can use “JMS inbound endpoints ” which can be deployed using manager node and only the workers will enable to use the JMS endpoint. (So manager node will not able to use JMS endpoint and consume any messages)
You can create JMS inbound endpoints using Manager management console or WSO2 Developer Studio 3.8.0 [2]
Following is a sample JMS inbound which listens to an activemq message queue and forward the messages to a sequence called “request” [3].

 <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="jms_inbound" 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>  

Beauty of Inbound Endpoints

The JMS inbound endpoint can bypass the inbound side axis2 layer and directly inject messages to a given sequence. So it is not required to enable JMS listeners in both manager and worker nodes. But If you are using JMS producer then you need to define  JMS senders in worker nodes. This blog post [4] shows more details on working with inbound endpoints.


References 


[1] https://docs.wso2.com/display/CLUSTER44x/Clustering+ESB+4.9.0
[2]http://wso2.com/products/developer-studio/
[3]https://docs.wso2.com/display/ESB490/JMS+Inbound+Protocol
[4]http://jagathsa.blogspot.com/2015/06/http-inbound-coordination-with-wso2-esb.html