Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run two instances of Apache ActiveMQ in one system?

I am using apache-activemq-5.11.1 which is the stable version runs on JDK 7 (Major version 51.0), I am using JDK 7 Update 80. I had error if I run the same on JDK 6.

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/ac tivemq/console/Main : Unsupported major.minor version 51.0

Coming to my problem I need to have two running instances of ActiveMQ in my system. I had followed the following steps to create two instance.

C:\>cd \apache-activemq-5.11.1
C:\apache-activemq-5.11.1>.\bin\activemq create instance1
C:\apache-activemq-5.11.1>.\bin\activemq create instance2

I had changed to different set of port numbers for instance2 as below,

<!--EDITED: apache-activemq-5.11.1\instance2\conf\activemq.xml-->

    <transportConnectors>
        <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
        <transportConnector name="openwire" uri="tcp://0.0.0.0:61716?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="amqp" uri="amqp://0.0.0.0:5772?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61713?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1983?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61714?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    </transportConnectors>

Now I am starting instance1 & instance2 as follows.....

C:\apache-activemq-5.11.1\instance1\bin>instance1 start
C:\apache-activemq-5.11.1\instance1\bin>instance2 start

Among these the second instance which I am trying to start gives the following kahadb lock problem.....

 INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@7209d9af: startup date [Thu May 07 16:16:23 IST 2015]; root of context hierarchy
 INFO | PListStore:[C:\apache-activemq-5.11.1\data\localhost\tmp_storage] started
 INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\apache-activemq-5.11.1\data\kahadb]
 INFO | Database C:\apache-activemq-5.11.1\data\kahadb\lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: File 'C:\apache-activemq-5.11.1\data\kahadb\lock' could not be locked.

Please give a solution for this db lock issue.

like image 508
Dev Anand Sadasivam Avatar asked Dec 15 '22 14:12

Dev Anand Sadasivam


2 Answers

Make a replica of your ActiveMQ like apache-activemq-x.xx.x to apache-activemq-x.xx.x_2

Change the ports of apache-activemq-x.xx.x_2\conf\activemq.xml. Make sure the port numbers that you are changing are not in clash.

<!--EDIT: apache-activemq-5.11.1_2\conf\activemq.xml-->
<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61716?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5772?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61713?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1983?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61714?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

And along with port changes we have to correct jetty.xml http management console port as well.

<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
         <!-- the default port number for the web console -->
    <property name="host" value="0.0.0.0"/>
    <property name="port" value="8162"/>
</bean>

In this way you can run two services of ActiveMQ in one system.

like image 159
3 revs Avatar answered Mar 15 '23 01:03

3 revs


Running more instances created for ActiveMQ gives the Fail Over option.

In this way when one instance goes down for some reason. The other instance coming up automatically, since the first instance which locks the KahaDB is been released.

For this ports are not to be changed,- as we're configuring instances for Fail Over Mode.

C:\>cd \apache-activemq-5.11.1
C:\apache-activemq-5.11.1>.\bin\activemq create instance1
C:\apache-activemq-5.11.1>.\bin\activemq create instance2

Please start instances without changing any of the configuration. So when instance1 goes down for any reason, instance2 coming up.

C:\apache-activemq-5.11.1\instance1\bin>instance1 start
C:\apache-activemq-5.11.1\instance2\bin>instance2 start

I hope this must be the purpose of creating multiple instances under ActiveMQ. And more than this some more tweaky config. also available for Kahadb.

like image 24
2 revs Avatar answered Mar 15 '23 03:03

2 revs