Tuesday, August 13, 2013

How to connect 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.

    Friday, March 22, 2013

    How to connect WSO2 ESB with ActiveMQ

    This article will describes how to configure WSO2 ESB 4.6.0 to work with the JMS transport. WSO2 ESB can work as a JMS listener or sender. It will works with the various types of JMS brokers such as,
    1. ActiveMQ
    2. IBM MQ
    3. Websphere MQ
    4. MSMQ
    5. SwiftMQ
    6. Tibco EMS
    7. WSO2 Message Broker

    To demonstrate this article i am using ActiveMQ Broker. You can download ActiveMQ 5.5.1 from here.  To Work with that download WSO2 ESB from here.

    Start ActiveMQ

    1. Extract downloaded ActiveMQ,
         In linux : tar zxvf apache-activemq-5.5.1-bin.tar.gz


    Monday, February 11, 2013

    How to create H2 database from H2 DB engine UI

    Using following simple steps you can create your own H2 database with in few minutes.

    1. Download H2 database engine UI from here.

    2. Extract downloaded pack and go to the bin directory.
       ex : "/h2/bin"

    3. Start DB console.
        if you are in Linux : sh h2.sh
        if you are in windows : h2.bat


    4. Once you start it, you will see H2 database console you browser.
       "https://127.0.1.1:8082/login.jsp?jsessionid=db5908d78d9d265318c24cdcd69697a0"


       

















    5. if your console doesn't have H2 configuration go to the ".h2.server.properties" file locates in your home directory (Linux). if you are using windows this will be at user/documents and settings.

    6. Open it and add below entry in .h2.server.properties file.
     "2=Generic H2 (Embedded)|org.h2.Driver|jdbc\:h2\:LOCATION-OF-DATABASE-WANT-TO-CRATE"

    7. Now restart h2.sh and now you will see H2 configuration.

    8. Enter database name what you add in properties file and enter new user name and password to that database.

    9. Click connect button and now it creates new database and login to the database.


    Tuesday, January 22, 2013

    How to reset security in Jenkins


    One may accidentally set up security realm / authorization in such a way that you may no longer able to reconfigure Jenkins.
    When this happens, you can fix this by the following steps:
    1. Stop Jenkins (the easiest way to do this is to kill the servlet container.)
    2. Go to $JENKINS_HOME in the file system and find config.xml file.
    3. Open this file in the editor.
    4. Look for the true element in this file.
    5. Replace true with false
    6. Remove the elements authorizationStrategy and securityRealm
    7. Start Jenkins
    When Jenkins comes back, it's in the unsecured mode where everyone gets full access to the system.
    If this is still not working, trying renaming or deleting config.xml.

    https://wiki.jenkins-ci.org/display/JENKINS/Disable+security

    Sunday, January 20, 2013

    How to Install JENKINS RedHat Servers


    Here is the simple steps to install JENKINS on RHEL servers.

    • sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
    • sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
    • sudo yum install jenkins
    Now start JENKINS Server
    •   sudo /etc/init.d/jenkins start
    Same as above you can stop or restart jenkins server.

    •  sudo /etc/init.d/jenkins stop/restart 

    Monday, January 7, 2013

    How to create custom keystores to WSO2 CARBON servers

    By default all wso2 carbon servers shipped with the "wso2carbon.jks" as a default key-store. But  default keystore is not recommended to use in production environment due to the security vulnerabilities. So in that case custom keyso