Tuesday, June 11, 2013

How to monitor WSO2 ESB mediation statistics from WSO2 BAM

With this blog post you can setup WSO2 BAM with ESB to monitor statistics.

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!  


Monday, June 10, 2013

How to Configure ActiveMQ with WSO2 ESB 4.6.0 within TWO MINUTES

WSO2 ESB is allows to work with the JMS transport to send and receive messages to queues and topics of any JMS services. WSO2 ESB capable to work with multiple broker services such as,
  • WSO2 Message Broker
  • Active MQ
  • IBM WebSphere MQ
  • IBM WebSphere  Application Server
  • MSMQ
  • Tibco EMS
  • SwiftMQ

Hence many users trying to use WSO2 ESB with ActiveMQ this blog post will demonstrate how to configure ActiveMQ with ESB within 2 minutes.I am using ActiveMQ 5.5.1 and ESB 4.6.0.

        1. Download ActiveMQ from here. 
        2. Download WSO2 ESB from here.

        3. Extract "apache-activemq-5.5.1" open ACTIVEMQ_HOME/lib directory and copy below jars.  
   
  • activemq-core-5.5.1.jar
  • geronimo-j2ee-management_1.0_spec-1.0.jar
  • geronimo-jms_1.1_spec-1.1.1.jar


    NOTE :  If you are using ActiveMQ 5.5.8 distribution, there's no activemq-core-5.5.1.jar in lib directory. Please copy following jars.

    • activemq-broker-5.8.0 
    • activemq-client-5.8.0 
    • geronimo-j2ee-management_1.1_spec-1.0.1 
    • geronimo-jms_1.1_spec-1.1.1 

    4. Extract ESB distribution and copy above AvtiveMQ related jars in to the "ESB_HOME/repository/components/lib" directory. 

    5. Now JMS listner and JMS sender need to be enabled in ESB distribution to serve with the ActiveMQ message Broker. To Do that open "axis2.xml" located in "ESB_HOME/repository/conf/axis2"location.

    6. Uncomment JMS listener configurations as follows. we are enabling In Queue connection factory, Topic connection factory and default to listen JMS messages. How these 3 are work is if ESB has proxy service and in that proxy specifically mention proxy type to the JMS Queue it is using Queue connection factory. If proxy type mention topic,it uses topic connection factory. If there are nothing in proxy type it uses "default" but most of the times default also point to the JMS queue. 





    7. Now Uncomment lelow line from axis2.xml to enable JMS sender.



      
    8. Now start ActiveMQ broker. To do that open ActiveMQ_Home/bin and run activemq script as a "./ active start" command. Once you started successfully you will see ActiveMQ web console from "http://localhost:8161/admin/index.jsp"

    9. Finally start ESB server and send messages from ActiveMQ queue to ESB.