Details
Description
When starting Tomcat with two web applications that both use ActiveMQ VM connector-based brokers, one of the web apps will fail during startup because a VM broker already exists:
2011-01-13 17:28:40,803 [main] ERROR org.apache.activemq.broker.BrokerService - Failed to start ActiveMQ JMS Message Broker. Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localbroker,Type=Broker
javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localbroker,Type=Broker
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1554)
at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:540)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:444)
Even if we change the broker name, data directory and VM connector URIs between web apps, we still get this error. It should, ideally, be a flag where the broker can attempt to start a VM instance, and if one exists already, and the flag to use existing VM broker is enabled, the error shouldn't occur but reuse the existing broker. Alternatively, you should be able to have multiple VM brokers created with different names.
In our case, this broker and messaging service is a convenience to facilitate flushing of caches across a network of servers. In our use case, not being able to do so is not critical. So if something caused the broker to not start, we should be able to still start the application with errors logged but not halting the web application startup. So some parameter there would be helpful as well.