Alejandro Cuervo
Alejandro Cuervo

Reputation: 555

dynamic name for broker in ActiveMQ to run 2 or more instances in same machine

I need run 2 instances of a standalone application which uses JMS with a local ActiveMQ in the same machine. I have a jms-context configuration file that is loaded when the application starts. I use KahaDB as persistence adapter

File jms-context of both instances is the same, so property "brokerName" of the localBroker has the same name.

<bean id="broker" class="org.apache.activemq.xbean.XBeanBrokerService">
    <property name="useJmx" value="true"/>
    <property name="brokerName" value="fileProcessorLocalBroker"/>
    <property name="persistent" value="true"/>
    <property name="destinationPolicy" ref="destinationPolicy"/>
    <property name="managementContext" ref="managementContext"/>
    <property name="persistenceAdapter" ref="persistenceAdapter"/>
 ...
</bean>

When I run the second instance of my application I get the following:

2014-07-21 12:37:04,377 INFO [org.apache.activemq.store.SharedFileLocker] - <Database   activemq-data\fileProcessorLocalBroker\KahaDB\lock is locked... waiting 10 seconds for the database to be unlocked. Reason: java.io.IOException: File 'activemq-data\fileProcessorLocalBroker\KahaDB\lock' could not be locked.>

Is there anyway of use a dynamic name for the property brokerName of localbroker?

Regards

Upvotes: 0

Views: 272

Answers (1)

Tim Bish
Tim Bish

Reputation: 18376

ActiveMQ itself doesn't have support for starting up with dynamic Broker names. You can however use property expressions to read the name from some ENV value or other source which you define. See this article for some clues:

Upvotes: 1

Related Questions