Tuesday, June 11, 2013

How to enable auto reconnection in WSO2 ESB with ActiveMQ

If you followed my previous blog post, I guess you will be able to setup WSO2 ESB with ActiveMQ within few minutes.
Either you configured perfectly and messages communicated perfectly, if ActiveMQ goes stop or restarted, ESB console will print bunch of exceptions. Because ESB always connected with the respective JMS queues or topics with the JMS broker and once connection breaks ESB prints exceptions.

 [2013-06-11 15:10:21,815] ERROR - ServiceTaskManager Error receiving message for service : Sample_Proxy  
 javax.jms.JMSException: java.io.EOFException  
      at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)  
      at org.apache.activemq.ActiveMQMessageConsumer.dequeue(ActiveMQMessageConsumer.java:476)  
      at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:594)  
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.receiveMessage(ServiceTaskManager.java:513)  
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:420)  
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)  
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)  
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)  
      at java.lang.Thread.run(Thread.java:662)  
 Caused by: java.io.EOFException  
      at java.io.DataInputStream.readInt(DataInputStream.java:375)  
      at org.apache.activemq.openwire.OpenWireFormat.unmarshal(OpenWireFormat.java:275)  
      at org.apache.activemq.transport.tcp.TcpTransport.readCommand(TcpTransport.java:229)  
      at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:221)  
      at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:204)  
      ... 1 more  

"transport.jms.CacheLevel" is the parameter which used to reconnect to the broker in case of failure.This parameter need to be configured in each and every connection factories under JMS sender configurations.
To configure it, open axis2.xml located in  ESB_HOME/repository/conf/axis2/axist.xml". add "transport.jms.CacheLevel" parameter as follows.

Once ESB work with the parameter, Either broker goes failed or restarted you will see ESB console print reconnection messages like below.

 [2013-06-11 16:19:49,116] ERROR - ServiceTaskManager Reconnection attempt : 5 for service : Sample_Proxy failed. Next retry in 320 seconds  
 [2013-06-11 16:25:09,118] INFO - ServiceTaskManager Reconnection attempt : 6 for service : Sample_Proxy  
 [2013-06-11 16:25:09,119] INFO - ServiceTaskManager Task manager for service : Sample_Proxy [re-]initialized  
 [2013-06-11 16:25:10,119] INFO - ServiceTaskManager Reconnection attempt: 6 for service: Sample_Proxy was successful!  

1 comment:

Computine LTD said...

Well we are an IT organization i.e. Computine LTD reputed IT organization in London providing outstanding IT and web based services in all over the world. We are known as a best London IT service providers. We offers Cisco network services, application development services London, Mobile Development services , Network support services London and much more. If you need more details just log on to in www.computine.co.uk