You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Eric-AWL <er...@atosorigin.com> on 2009/02/17 19:02:38 UTC

Correctly leaving a network of broker

Hi 

I have two Java processes with their own embedded broker, linked together
with a multicast network of broker.

I start the "server process" which first creates its broker and connects
itself to it.
Then, I start the "client process" which first creates its broker, and
connects itself to it.

The network of broker is automatically created and all my messages sent by
the client to the server are received. And all answers sent by the server
are received by the client. Very well !

Then I ask the client to gracefully disconnect from its broker (JMS
disconnect). I think disconnect is OK, then my process wants to stop, but
has to wait until I break "CTRL-C" my server process.

I imagine there are some active threads which don't want to stop. Is there a
good way to gracefully ask my client to stop the ActiveMQ threads which are
used by the network of broker ?

Until now, I only use JMS methods. And I prefer to continue, if it's
possible (a connection parameter ?)

Thank you
Eric
-- 
View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22062875.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Correctly leaving a network of broker

Posted by Eric-AWL <er...@atosorigin.com>.
OK It works !!!

When I disconnect from my embedded connection, I stop my embedded broker and
the process exits gracefully.

I just had to add 4 ActiveMQ specific lines in my JMS compliant Connection
Class. It would be better if it was an external parameter of the URI but it
is a good workaround.

Thank you
Eric





-- 
View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22117822.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Correctly leaving a network of broker

Posted by Eric-AWL <er...@atosorigin.com>.

Ouch. I just looked at "borkerFactory" class. (I tried not to use ActiveMQ
internals ... And never looked at it)

No problem Gary. I understood your advice. The last question is not
appropriate. Forget it please.

Eric

Eric-AWL wrote:
> 
> Hi Gary
> 
> Yes, it helps me. Thank you. 
> 
> I understand that, if I have a Java reference of the embedded
> brokerService object, and use brokerService.stop(), I will gracefully quit
> the network of broker . Good ! It's the main part of my question.
> 
> 
> You told me that I can continue to use my URI syntax. It's a very good
> thing for me to have the activemq embedded broker configuration
> externalized into a standard configuration file.
> 
> Can you precise how I get a reference on the brokerService that will be
> created (not started) with such 
> a method, to start and stop it as I want ?
> 
> Thank you
> Eric
> 
> Gary Tully wrote:
>> 
>> Hi Eirc,
>> 
>> If you want to access the broker service you should use the
>> org.apache.activemq.broker.BrokerFactory to create it and return a
>> reference. The create takes the same uri syntax as a
>> connectionFactory.
>> The details can be found at:
>> http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
>> 
>> stopping the client broker service will gracefully disconnect it from
>> the server side (networked) broker. You can still use the vm: url to
>> connect to the broker but you may want to add create=false to the uri
>> so that you don't end up with two embedded brokers.
>> 
>> hope this helps,
>> Gary.
>> 
>> 2009/2/18 Eric-AWL <er...@atosorigin.com>:
>>>
>>> I use xbean reference to an activemq.xml file to read a VM configuration
>>> on
>>> each side.
>>>
>>> "vm://instance?brokerConfig=xbean:activemq.xml&waitForStart=2"
>>>
>>> I like this method because I can switch from internal VM broker to TCP
>>> external broker very easily and just use JMS to connect to my internal
>>> or
>>> external broker without using ActiveMQ classes.
>>>
>>> If I manage ActiveMQ BrokerService Objects myself and manually create a
>>> broker in my program, Will "brokerService.stop()" stop the internal
>>> broker
>>> and allow my client program to stop gracefully without affecting my
>>> server
>>> process ?
>>>
>>> If yes, is there a way to get a BrokerService JAVA reference for a VM
>>> broker
>>> automatically created with an xbean reference to an ActiveMQ.xml file ?
>>>
>>> Eric
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22083464.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> 
>> -- 
>> http://blog.garytully.com
>> 
>> Open Source SOA
>> http://FUSESource.com
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22116899.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Correctly leaving a network of broker

Posted by Eric-AWL <er...@atosorigin.com>.
Hi Gary

Yes, it helps me. Thank you. 

I understand that, if I have a Java reference of the embedded brokerService
object, and use brokerService.stop(), I will gracefully quit the network of
broker . Good ! It's the main part of my question.


You told me that I can continue to use my URI syntax. It's a very good thing
for me to have the activemq embedded broker configuration externalized into
a standard configuration file.

Can you precise how I get a reference on the brokerService that will be
created (not started) with such 
a method, to start and stop it as I want ?

Thank you
Eric

Gary Tully wrote:
> 
> Hi Eirc,
> 
> If you want to access the broker service you should use the
> org.apache.activemq.broker.BrokerFactory to create it and return a
> reference. The create takes the same uri syntax as a
> connectionFactory.
> The details can be found at:
> http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
> 
> stopping the client broker service will gracefully disconnect it from
> the server side (networked) broker. You can still use the vm: url to
> connect to the broker but you may want to add create=false to the uri
> so that you don't end up with two embedded brokers.
> 
> hope this helps,
> Gary.
> 
> 2009/2/18 Eric-AWL <er...@atosorigin.com>:
>>
>> I use xbean reference to an activemq.xml file to read a VM configuration
>> on
>> each side.
>>
>> "vm://instance?brokerConfig=xbean:activemq.xml&waitForStart=2"
>>
>> I like this method because I can switch from internal VM broker to TCP
>> external broker very easily and just use JMS to connect to my internal or
>> external broker without using ActiveMQ classes.
>>
>> If I manage ActiveMQ BrokerService Objects myself and manually create a
>> broker in my program, Will "brokerService.stop()" stop the internal
>> broker
>> and allow my client program to stop gracefully without affecting my
>> server
>> process ?
>>
>> If yes, is there a way to get a BrokerService JAVA reference for a VM
>> broker
>> automatically created with an xbean reference to an ActiveMQ.xml file ?
>>
>> Eric
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22083464.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> http://blog.garytully.com
> 
> Open Source SOA
> http://FUSESource.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22116313.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Correctly leaving a network of broker

Posted by Gary Tully <ga...@gmail.com>.
Hi Eirc,

If you want to access the broker service you should use the
org.apache.activemq.broker.BrokerFactory to create it and return a
reference. The create takes the same uri syntax as a
connectionFactory.
The details can be found at:
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

stopping the client broker service will gracefully disconnect it from
the server side (networked) broker. You can still use the vm: url to
connect to the broker but you may want to add create=false to the uri
so that you don't end up with two embedded brokers.

hope this helps,
Gary.

2009/2/18 Eric-AWL <er...@atosorigin.com>:
>
> I use xbean reference to an activemq.xml file to read a VM configuration on
> each side.
>
> "vm://instance?brokerConfig=xbean:activemq.xml&waitForStart=2"
>
> I like this method because I can switch from internal VM broker to TCP
> external broker very easily and just use JMS to connect to my internal or
> external broker without using ActiveMQ classes.
>
> If I manage ActiveMQ BrokerService Objects myself and manually create a
> broker in my program, Will "brokerService.stop()" stop the internal broker
> and allow my client program to stop gracefully without affecting my server
> process ?
>
> If yes, is there a way to get a BrokerService JAVA reference for a VM broker
> automatically created with an xbean reference to an ActiveMQ.xml file ?
>
> Eric
>
> --
> View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22083464.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
http://blog.garytully.com

Open Source SOA
http://FUSESource.com

Re: Correctly leaving a network of broker

Posted by Eric-AWL <er...@atosorigin.com>.
I use xbean reference to an activemq.xml file to read a VM configuration on
each side.

"vm://instance?brokerConfig=xbean:activemq.xml&waitForStart=2"

I like this method because I can switch from internal VM broker to TCP
external broker very easily and just use JMS to connect to my internal or
external broker without using ActiveMQ classes.

If I manage ActiveMQ BrokerService Objects myself and manually create a
broker in my program, Will "brokerService.stop()" stop the internal broker
and allow my client program to stop gracefully without affecting my server
process ?

If yes, is there a way to get a BrokerService JAVA reference for a VM broker
automatically created with an xbean reference to an ActiveMQ.xml file ?

Eric

-- 
View this message in context: http://www.nabble.com/Correctly-leaving-a-network-of-broker-tp22062875p22083464.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.