You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by taf <to...@fikse.net> on 2008/08/28 13:45:16 UTC

Restart of embedded broker causes BrokerStoppedException

Hi,
I'm running activemq embedded and wants to be able to restart the broker
without terminating the host application. The broker starts fine on
application startup and calling stop() therafter also works fine, but when
trying to start it again, it results in a BrokerStoppedException.

I've traced the call into the start method in MutableBrokerFilter where the
call to getNext().start() actually returns an ErrorBroker (which of-course
gives me a BrokerStoppedException when trying to start it).

I would have thought that the call should be this.start(), as my broker is
successfully bound to this.
And why does getNext even return an ErrorBroker?

Am I missing something obvious here?

Regards,
- Torgeir Fikse


-- 
View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19198844.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Restart of embedded broker causes BrokerStoppedException

Posted by taf <to...@fikse.net>.
More digging done...

I guess this is the same issue as mentioned in
http://osdir.com/ml/java.activemq.user/2005-12/msg00087.html

and it seems like the cause is that when stopping the broker an "ErrorBroker
filter" is added to intercept any calls to the stopped broker (a good thing
(tm)). 
But since the succeeding start call uses the same instance of the broker as
stop did it's intercepted by the ErrorBroker filter when trying to start it
thus causing a BrokerStoppedException.

A solution is to create a new instance of the broker, but shouldn't actually
a call to start() remove any ErrorBroker filters being placed there when
stopping it?

- Torgeir


taf wrote:
> 
> Hi,
> I'm running activemq embedded and wants to be able to restart the broker
> without terminating the host application. The broker starts fine on
> application startup and calling stop() therafter also works fine, but when
> trying to start it again, it results in a BrokerStoppedException.
> 
> I've traced the call into the start method in MutableBrokerFilter where
> the call to getNext().start() actually returns an ErrorBroker (which
> of-course gives me a BrokerStoppedException when trying to start it).
> 
> I would have thought that the call should be this.start(), as my broker is
> successfully bound to this.
> And why does getNext even return an ErrorBroker?
> 
> Am I missing something obvious here?
> 
> Regards,
> - Torgeir Fikse
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19202162.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Restart of embedded broker causes BrokerStoppedException

Posted by Gary Tully <ga...@gmail.com>.
It should do, provided all threads get to do their thing at shutdown.

2008/9/30 taf <to...@fikse.net>:
>
> This problem is not appearing in the latest snapshot (2008-09-29).
>
> Another issue surfaced though; when restarting the broker the journal is
> still locked. Isn't the broker.stop() suppose to unlock the journal if it's
> the only (or last) broker running?
>
>
>
>
> taf wrote:
>>
>> Hi,
>> I'm running activemq embedded and wants to be able to restart the broker
>> without terminating the host application. The broker starts fine on
>> application startup and calling stop() therafter also works fine, but when
>> trying to start it again, it results in a BrokerStoppedException.
>>
>> I've traced the call into the start method in MutableBrokerFilter where
>> the call to getNext().start() actually returns an ErrorBroker (which
>> of-course gives me a BrokerStoppedException when trying to start it).
>>
>> I would have thought that the call should be this.start(), as my broker is
>> successfully bound to this.
>> And why does getNext even return an ErrorBroker?
>>
>> Am I missing something obvious here?
>>
>> Regards,
>> - Torgeir Fikse
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19737754.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Re: Restart of embedded broker causes BrokerStoppedException

Posted by taf <to...@fikse.net>.
This problem is not appearing in the latest snapshot (2008-09-29).

Another issue surfaced though; when restarting the broker the journal is
still locked. Isn't the broker.stop() suppose to unlock the journal if it's
the only (or last) broker running?




taf wrote:
> 
> Hi,
> I'm running activemq embedded and wants to be able to restart the broker
> without terminating the host application. The broker starts fine on
> application startup and calling stop() therafter also works fine, but when
> trying to start it again, it results in a BrokerStoppedException.
> 
> I've traced the call into the start method in MutableBrokerFilter where
> the call to getNext().start() actually returns an ErrorBroker (which
> of-course gives me a BrokerStoppedException when trying to start it).
> 
> I would have thought that the call should be this.start(), as my broker is
> successfully bound to this.
> And why does getNext even return an ErrorBroker?
> 
> Am I missing something obvious here?
> 
> Regards,
> - Torgeir Fikse
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19737754.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Restart of embedded broker causes BrokerStoppedException

Posted by taf <to...@fikse.net>.
Sorry, I had to leave this issue for a while, but am now on it again.

I've made a simple test to restart the broker, but get the same exception as
previously; BrokerStoppedException.

import org.apache.activemq.broker.BrokerService;
public static void main(String[] args) {
    try {
	BrokerService broker = new BrokerService();
	broker.start();
	broker.stop();
	broker.waitUntilStopped();
	broker.start();
    } catch (Exception e) {
	e.printStackTrace();
    }
}

I've checked the units tests (version 5.1.0) for restarting a broker, but
appearantly this just emulates a restart by creating a new instance before
the second start is called.

Is it possible in some way to actually restart the same instance, or do I
have to create a new (and thereby have to reload the entrie configuration)?

Thanks for any help on this.


- Torgeir



Gary Tully wrote:
> 
> sorry, that mail was sent a little prematurely.
> 
> just to add that it should be possible to loop around broker.start()
> and broker.stop() once the broker.waitUntilStopped() is used.
> 
> 2008/8/28 Gary Tully <ga...@gmail.com>:
>> You might want to post your code so we can take a peek.
>> Stop is async, so it could be that the broker is not fully stopped.
>>
>> One thing that that help is if you add a call to waitUntilStopped().
>>
>> while(...) {
>> broker.start();
>> broker.stop(0;
>> broker.waitUntilStopped();
>>
>> 2008/8/28 taf <to...@fikse.net>:
>>>
>>> Hi,
>>> I'm running activemq embedded and wants to be able to restart the broker
>>> without terminating the host application. The broker starts fine on
>>> application startup and calling stop() therafter also works fine, but
>>> when
>>> trying to start it again, it results in a BrokerStoppedException.
>>>
>>> I've traced the call into the start method in MutableBrokerFilter where
>>> the
>>> call to getNext().start() actually returns an ErrorBroker (which
>>> of-course
>>> gives me a BrokerStoppedException when trying to start it).
>>>
>>> I would have thought that the call should be this.start(), as my broker
>>> is
>>> successfully bound to this.
>>> And why does getNext even return an ErrorBroker?
>>>
>>> Am I missing something obvious here?
>>>
>>> Regards,
>>> - Torgeir Fikse
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19198844.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19720050.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Restart of embedded broker causes BrokerStoppedException

Posted by Gary Tully <ga...@gmail.com>.
sorry, that mail was sent a little prematurely.

just to add that it should be possible to loop around broker.start()
and broker.stop() once the broker.waitUntilStopped() is used.

2008/8/28 Gary Tully <ga...@gmail.com>:
> You might want to post your code so we can take a peek.
> Stop is async, so it could be that the broker is not fully stopped.
>
> One thing that that help is if you add a call to waitUntilStopped().
>
> while(...) {
> broker.start();
> broker.stop(0;
> broker.waitUntilStopped();
>
> 2008/8/28 taf <to...@fikse.net>:
>>
>> Hi,
>> I'm running activemq embedded and wants to be able to restart the broker
>> without terminating the host application. The broker starts fine on
>> application startup and calling stop() therafter also works fine, but when
>> trying to start it again, it results in a BrokerStoppedException.
>>
>> I've traced the call into the start method in MutableBrokerFilter where the
>> call to getNext().start() actually returns an ErrorBroker (which of-course
>> gives me a BrokerStoppedException when trying to start it).
>>
>> I would have thought that the call should be this.start(), as my broker is
>> successfully bound to this.
>> And why does getNext even return an ErrorBroker?
>>
>> Am I missing something obvious here?
>>
>> Regards,
>> - Torgeir Fikse
>>
>>
>> --
>> View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19198844.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>

Re: Restart of embedded broker causes BrokerStoppedException

Posted by Gary Tully <ga...@gmail.com>.
You might want to post your code so we can take a peek.
Stop is async, so it could be that the broker is not fully stopped.

One thing that that help is if you add a call to waitUntilStopped().

while(...) {
broker.start();
broker.stop(0;
broker.waitUntilStopped();

2008/8/28 taf <to...@fikse.net>:
>
> Hi,
> I'm running activemq embedded and wants to be able to restart the broker
> without terminating the host application. The broker starts fine on
> application startup and calling stop() therafter also works fine, but when
> trying to start it again, it results in a BrokerStoppedException.
>
> I've traced the call into the start method in MutableBrokerFilter where the
> call to getNext().start() actually returns an ErrorBroker (which of-course
> gives me a BrokerStoppedException when trying to start it).
>
> I would have thought that the call should be this.start(), as my broker is
> successfully bound to this.
> And why does getNext even return an ErrorBroker?
>
> Am I missing something obvious here?
>
> Regards,
> - Torgeir Fikse
>
>
> --
> View this message in context: http://www.nabble.com/Restart-of-embedded-broker-causes-BrokerStoppedException-tp19198844p19198844.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>