You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Ueli Scheidegger <us...@fastforward.ch> on 2014/04/14 11:19:40 UTC

Embedded queue: how to share within 1 VM but 2 web apps?

Dear ActiveMQ experts

(Sorry if this get's reposted. Nabble was telling my that my post was not accepted.)

I'm trying to figure out a thing which should be easy according to the docs[1]. 

I have 
- 1 Tomcat (therefore 1 VM)
- 2 webapps

Now I need 1 embedded message queue in this VM which is shared between the two web apps. I don't create the BrokerService manually but rather use a connection factory in both web apps:

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://queuename");

Producing and consuming works fine on one web app. However when I try to do the same on the second web app I get barked at that the queue already exists:

2014-03-18 14:24:37,540 WARN  org.apache.activemq.broker.jmx.ManagementContext  : Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create jmx connector, trying to remedy this issue.
2014-03-18 14:24:37,545 ERROR org.apache.activemq.broker.BrokerService          : Failed to start Apache ActiveMQ (queuename, null). Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName= queuename,Type=Broker
javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName= queuename,Type=Broker
 at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)

I also tried with "vm://queuename?create=false" but got an error telling me that the broker would not exist… So now I'm a bit desperate. Googled high and low but could not find an answer so far. Therefore any help warmly appreciated!

Thanks,
will

[1] http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html