How do I run two instances of Apache ActiveMQ on the same system?

I am using apache-activemq-5.11.1 which is the stable version running on JDK 7 (major version 51.0), I am using JDK 7 Update 80. I had an error if I run it on JDK 6.

Exception on 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 ActiveMQ instances running on my system. I followed the steps below to create two instances.

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 changed to a different set of port numbers for example2 as shown 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 run instance1 and instance2 like this .....

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

      

Among them, the second instance I am trying to start gives the following kahadb blocking 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 to this db blocking problem.

+3


source to share


5 answers


Make a copy of your ActiveMQ as apache-activemq-x.xx.x

beforeapache-activemq-x.xx.x_2

Change the ports apache-activemq-x.xx.x_2\conf\activemq.xml

. Make sure the port numbers you are changing are not in conflict.

<!--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 the port changes, we also need to fix the management console port http: // http: // http: // http: //.

<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>

      

This way you can run two ActiveMQ services on the same system.

+4


source


Running more instances created for ActiveMQ gives the option "Crash".

So for some reason, one instance crashes. Another instance automatically appears because the first instance that KahaDB locks was freed.

For this, the ports do not need to be changed as we are configuring the 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 run instances without changing any configuration. So when instance 1 descends for whatever reason, instance2 appears.

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

      

Hopefully this should be the goal of creating multiple instances in ActiveMQ. And more than this even thinner config. also available for Kahadb.

+2


source


what happens, you changed the port numbers correctly, but both instances you created used the same database (in this case the KahaDB filesystem) to store their messages,

So, when one instance is up and running, it holds a lock for that database, and another instance of activeMQ will wait to acquire a lock on that database. This essentially becomes the master subordinate configuration.

look at this line in activeMQ.xml

<persistenceAdapter>
      <kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>

      

this will point to the same location for both instances.

what solution to copy the whole folder apache-activemq-x.xx.x

to another location changes the port numbers for the second instance and runs them differently this you will have 2 instances of activeMQ running on the same computer

hope this helps!

Good luck!

+1


source


I followed the instructions below:

It works great for Mac

(not tested in Linux

)

Note : instances must be started via instanceNumber start

(the console argument / parameter is no longer valid).

I had the same problem with kahadb

blocking only for Windows

, for versions ActiveMQ

5.13.3 and 5.14.5

The same author from DZone wrote almost the same post on his blog

But there is an important update.

You have to open each instanceNumber.bat

file for each instance from each directory bin

and add these two lines:

set ACTIVEMQ_CONF="ACTIVEMQ_HOME/instanceNumber/conf"
set ACTIVEMQ_DATA="ACTIVEMQ_HOME/instanceNumber/data"

      

Where ACTIVEMQ_HOME

represents the location of your path ActiveMQ

and instanceNumber

is the instance being edited, such as: instanceA

andinstanceB

+1


source


Although due to the KahaDB

limitation of the load balancing / failover configuration is limited. We can use the following kind of connection url to use the ActiveMQ load ....

failover://(tcp://192.nnn.nn.nn:61616,tcp://192.nnn.nn.nn:61616)?randomize=false

      

randomize=true

will make shuffling messages between two AciveMQs in active mode, not just ActiveMQ crashing ......

A complete link for this can be found at the following link on the Apache Site ....

http://activemq.apache.org/failover-transport-reference.html

But still high availability (like clustered) configuration makes things stable for your application, although Apache has to promote ActiveMQ High Availability so things can run smoother.

The current Apache ActiveMQ high availability configuration is available at the following link.

http://activemq.apache.org/clustering.html

Although it KahaDB

has a limitation on file locking, the following settings / alternative configuration methods can be done ...

1) The main slave to the filesystem is a shared filesystem like SAN http://activemq.apache.org/shared-file-system-master-slave.html

2) JDBC Master Submission, - General Database http://activemq.apache.org/jdbc-master-slave.html

3) Replicated LevelDB storage, - ZooKeeper Server http://activemq.apache.org/replicated-leveldb-store.html

Above and above, having JCA connectors like JBoss, Weblogic, Websphere, Geronimo, Glassfish - fix ActimeMQ as a kind of resource adapter. And with Apache Camel (karaf), JBoss Fuse ESB, HA product view and ActiveMQ clustering can be done.

-1


source







All Articles