You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "james (JIRA)" <ji...@apache.org> on 2014/03/24 20:56:43 UTC

[jira] [Commented] (AMQ-5118) Race condition with embedded broker asynchronous startup

    [ https://issues.apache.org/jira/browse/AMQ-5118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945617#comment-13945617 ] 

james commented on AMQ-5118:
----------------------------

Note that i've found a workaround for now.  If i call BrokerService.getBroker() before calling BrokerService.start(), the internal broker instance is created and assigned before the rest of startup proceeds and there is no longer a race condition with the connection factory startup.  During a normal BrokerService (asynchronous) startup, the Broker instance is not created until after the persistence adapters are started.  I'm not sure what the implications of my workaround are (creating the broker instance before the persistence adapters are started) but everything seems to be working fine with this change in place.

Assuming that creating the broker instance earlier in the startup process is legitimate, maybe the BrokerService could be changed to do that in the start() method before breaking off for the rest of the asynchronous startup process.

> Race condition with embedded broker asynchronous startup
> --------------------------------------------------------
>
>                 Key: AMQ-5118
>                 URL: https://issues.apache.org/jira/browse/AMQ-5118
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.9.0
>            Reporter: james
>
> We run activemq as an embedded broker using the asynchronous startup option.  After the start async call returns, we create a vm connector with the extra options "?create=false&waitForStart=60000".  There is a timing hole where the BrokerService has been registered with the BrokerRegistry (and is found by the connection factory), but the BrokerServer.broker member variable has not yet been assigned (in fact, there may be some memory visibility issues here).  The VMTransportFactory eventually generates a call to BrokerService.getBroker(), which (since broker == null) attempts to create a broker instance.  This ultimately results in a JMX exception due to multiple instances being registered (assuming you have jmx enabled).
> {noformat}
> javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Status MBean could not be registe
> red in JMX: org.apache.activemq:type=Broker,brokerName=internal,service=Health
>   at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
>   at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:260)
>   at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:273)
>   at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:246)
>   at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:186)
>   at <internal stacktrace ommitted>
>   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
>   at java.lang.Thread.run(Thread.java:662)
> Caused by: java.io.IOException: Status MBean could not be registered in JMX: org.apache.activemq:type=Broker,brokerName=internal,service=Health
>   at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
>   at org.apache.activemq.broker.BrokerService.addInterceptors(BrokerService.java:2242)
>   at org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:2123)
>   at org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:906)
>   at org.apache.activemq.broker.TransportConnector.start(TransportConnector.java:201)
>   at org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:140)
>   at org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:54)
>   at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:64)
>   at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:258)
>   ... 37 more
> Caused by: javax.management.InstanceAlreadyExistsException: org.apache.activemq:type=Broker,brokerName=internal,service=Health
>   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:483)
>   at org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:380)
>   at org.apache.activemq.broker.jmx.AnnotatedMBean.registerMBean(AnnotatedMBean.java:72)
>   at org.apache.activemq.broker.BrokerService.addInterceptors(BrokerService.java:2240)
>   ... 44 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)