Tuesday, August 13, 2013

How to connet multiple ActiveMQ Brokers to WSO2 Enterprice Service Bus

Common use case scenario is work WSO2 ESB with one broker service. But when it goes to production deployment it may need to have more than one broker service due to maintain high availability in the production system. WSO2 ESB facilitate to connect more than one ActiveMQ brokers to serve above requirement.

Common use-case :
 Multiple  Broker use-case




Following are the steps need to be taken in to configure WSO2 ESB to work with the multiple ActiveMQ brokers.

1. Configure one ActiveMQ broker with ESB instance like common use-case. Please follow my previous blog post to do that.
2. Now start another ActiveMQ instance.
3. Assume first ActiveMQ instance port is 61616, second instance port is 61617.
4. Open axis2.xml located in ESB_HOME/repository/conf/axis2/ location
5. Now you already have one JMS receiver like follows.



    6. Add another new transport receiver as follows. make sure to change "transportReceiver name". this will be second transport receiver.




    7. Now start ESB server. ESB console will prints below messages once ESB server successfully connected to the both ActiveMQ brokers.


    INFO - PassThroughHttpListener Initializing Pass-through HTTP/S Listener...
    INFO - JMSConnectionFactory JMS ConnectionFactory : myTopicConnectionFactory initialized
    INFO - JMSConnectionFactory JMS ConnectionFactory : myQueueConnectionFactory initialized
    INFO - JMSConnectionFactory JMS ConnectionFactory : default initialized
    INFO - JMSListener JMS Transport Receiver/Listener initialized...
    INFO - JMSConnectionFactory JMS ConnectionFactory : myTopicConnectionFactory initialized
    INFO - JMSConnectionFactory JMS ConnectionFactory : myQueueConnectionFactory initialized
    INFO - JMSConnectionFactory JMS ConnectionFactory : default initialized
    INFO - JMSListener JMS Transport Receiver/Listener initialized...


    8. Now you can create sample proxy service by adding both JMS listners. It will listen to both ActiveMQ broker queues.

     



    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.




    Friday, March 29, 2013

    How to deactivate monitor sleep in Raspbery Pi

    This is my personal experience. I have installed "Raspbery Pi Wheezy" in to my raspberry pi. I used it to display some browser based dashboard and it going to sleep mode frequently. i found this solution from one of the site i couldn't' remember what it is. Following was the solution what i have used to avoid this issue. It's worked perfect.

    1. Open a root terminal in raspberry Pi. Now  you need to edit your script that's starting X. In the default build with lightdm.
    2. Open "lightdm.conf" file located in, 

         /etc/lightdm/lightdm.conf

    3. Add below line in to SeatDefault section.
    [SeatDefaults]
    xserver-command=X -s 0 -dpms
    4. Restart your Raspberry Pi.
    Now issue should be solved.