Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5F4C810236 for ; Mon, 24 Mar 2014 19:56:51 +0000 (UTC) Received: (qmail 63135 invoked by uid 500); 24 Mar 2014 19:56:46 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 62996 invoked by uid 500); 24 Mar 2014 19:56:44 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 62823 invoked by uid 99); 24 Mar 2014 19:56:43 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Mar 2014 19:56:43 +0000 Date: Mon, 24 Mar 2014 19:56:43 +0000 (UTC) From: "james (JIRA)" To: dev@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AMQ-5118) Race condition with embedded broker asynchronous startup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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 > 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)