You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Ruben de Gooijer <r....@onehippo.com> on 2009/05/07 19:42:24 UTC

BrokerStoppedException, during embedded broker restart

Hi all,

I have a simple test using an embedded activemq 5.2.0 that performs a system
restart.

public class ActiveMQEmbeddedLifecycleTest extends TestCase
{
    public void testLifecycle() throws Exception
    {
        BrokerService service =
BrokerFactory.createBroker("xbean:activemq.xml");
        service.start();

        assertEquals(true, service.isStarted());

        service.stop();
        service.waitUntilStopped();

        assertEquals(false, service.isStarted());

        service.start();

        assertEquals(true, service.isStarted());

        service.stop();
    }
}

The error message I get while execution this test:

ERROR [main] (BrokerService.java:491) - Failed to start ActiveMQ JMS Message
Broker. Reason: org.apache.activemq.broker.BrokerStoppedException: Broker
has been stopped: org.apache.activemq.broker.BrokerService$3@164b09c
org.apache.activemq.broker.BrokerStoppedException: Broker has been stopped:
org.apache.activemq.broker.BrokerService$3@164b09c
    at org.apache.activemq.broker.ErrorBroker.start(ErrorBroker.java:172)
    at
org.apache.activemq.broker.MutableBrokerFilter.start(MutableBrokerFilter.java:161)
    at
org.apache.activemq.broker.BrokerService.start(BrokerService.java:468)
    at
org.hippoecm.hipposponge.test.ActiveMQEmbeddedLifecycleTest.testLifecycle(ActiveMQEmbeddedLifecycleTest.java:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
    at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
    at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

While searching on through the mailinglist archives I found a thread that
expresses the same problem.
http://markmail.org/message/lqtas5u7ehnzetdt#query:+page:1+mid:fextmpkjwt64yodh+state:results

Although it seems that there the problem has been solved, with the release I
am using it still causes trouble.

activemq.xml:

<amq:broker
        useShutdownHook="false"
        useJmx="false"
        persistent="true"
        brokerName="localhost" >
        <amq:transportConnectors>
            <amq:transportConnector
uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=-1" />
            <amq:transportConnector
uri="vm://localhost:61616?wireFormat.maxInactivityDuration=-1" />
        </amq:transportConnectors>
        <amq:persistenceAdapter>
            <amq:kahaPersistenceAdapter maxDataFileLength="33554432"/>
        </amq:persistenceAdapter>
    </amq:broker>
</beans>

Kind regards,
Ruben

Re: BrokerStoppedException, during embedded broker restart

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Ruben,

usually you'll have to initialize your broker again after it has been
stopped. I just implemented the "forced" restart feature for 5.3. Take a
look at

http://cwiki.apache.org/confluence/display/ACTIVEMQ/How+do+I+restart+embedded+brokerand
https://issues.apache.org/activemq/browse/AMQ-2245

for more details.

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Thu, May 7, 2009 at 7:42 PM, Ruben de Gooijer
<r....@onehippo.com>wrote:

> Hi all,
>
> I have a simple test using an embedded activemq 5.2.0 that performs a
> system
> restart.
>
> public class ActiveMQEmbeddedLifecycleTest extends TestCase
> {
>    public void testLifecycle() throws Exception
>    {
>        BrokerService service =
> BrokerFactory.createBroker("xbean:activemq.xml");
>        service.start();
>
>        assertEquals(true, service.isStarted());
>
>        service.stop();
>        service.waitUntilStopped();
>
>        assertEquals(false, service.isStarted());
>
>        service.start();
>
>        assertEquals(true, service.isStarted());
>
>        service.stop();
>    }
> }
>
> The error message I get while execution this test:
>
> ERROR [main] (BrokerService.java:491) - Failed to start ActiveMQ JMS
> Message
> Broker. Reason: org.apache.activemq.broker.BrokerStoppedException: Broker
> has been stopped: org.apache.activemq.broker.BrokerService$3@164b09c
> org.apache.activemq.broker.BrokerStoppedException: Broker has been stopped:
> org.apache.activemq.broker.BrokerService$3@164b09c
>    at org.apache.activemq.broker.ErrorBroker.start(ErrorBroker.java:172)
>    at
>
> org.apache.activemq.broker.MutableBrokerFilter.start(MutableBrokerFilter.java:161)
>    at
> org.apache.activemq.broker.BrokerService.start(BrokerService.java:468)
>    at
>
> org.hippoecm.hipposponge.test.ActiveMQEmbeddedLifecycleTest.testLifecycle(ActiveMQEmbeddedLifecycleTest.java:23)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    at java.lang.reflect.Method.invoke(Method.java:585)
>    at junit.framework.TestCase.runTest(TestCase.java:154)
>    at junit.framework.TestCase.runBare(TestCase.java:127)
>    at junit.framework.TestResult$1.protect(TestResult.java:106)
>    at junit.framework.TestResult.runProtected(TestResult.java:124)
>    at junit.framework.TestResult.run(TestResult.java:109)
>    at junit.framework.TestCase.run(TestCase.java:118)
>    at junit.framework.TestSuite.runTest(TestSuite.java:208)
>    at junit.framework.TestSuite.run(TestSuite.java:203)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    at java.lang.reflect.Method.invoke(Method.java:585)
>    at
> org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
>    at
>
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>    at
>
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    at java.lang.reflect.Method.invoke(Method.java:585)
>    at
>
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
>    at
>
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
>
> While searching on through the mailinglist archives I found a thread that
> expresses the same problem.
>
> http://markmail.org/message/lqtas5u7ehnzetdt#query:+page:1+mid:fextmpkjwt64yodh+state:results
>
> Although it seems that there the problem has been solved, with the release
> I
> am using it still causes trouble.
>
> activemq.xml:
>
> <amq:broker
>        useShutdownHook="false"
>        useJmx="false"
>        persistent="true"
>        brokerName="localhost" >
>        <amq:transportConnectors>
>            <amq:transportConnector
> uri="tcp://localhost:61616?wireFormat.maxInactivityDuration=-1" />
>            <amq:transportConnector
> uri="vm://localhost:61616?wireFormat.maxInactivityDuration=-1" />
>        </amq:transportConnectors>
>        <amq:persistenceAdapter>
>            <amq:kahaPersistenceAdapter maxDataFileLength="33554432"/>
>        </amq:persistenceAdapter>
>    </amq:broker>
> </beans>
>
> Kind regards,
> Ruben
>