You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Paul French <pa...@frenchiesystems.com> on 2006/07/28 19:31:51 UTC

running a jms client with mulitple threads

I have a work around but I'm wondering if anyone else has a better idea?

I use a PooledConnectionfactory for my JMS connections.

I start say 10 threads from my main thread all part of the same thread
group. They send some JMS messages and then finish.

I need to detect when all the threads have finshed so I can close the
PooledConnectionFactory by calling stop() to release the system resources.

The problem I have is the first JMS call within one of the new threads
starts up the acivemq processes on the client (3 of them, a connection and 2
schedulers) and they automatically become part of my ThreadGroup. These
threads never die!! Hence even when all my threads stop I still have active
activemq threads part of the threadgroup.

I did a work around by calling start on the PooledConnectionFactory from
within the main thread before I started my 10 threads. Then it is easy to
check the threadgroup active count is zero before I call stop().

Any better ideas since I'm not sure if I will always have the luxury of
pre-starting the connection pool.
-- 
View this message in context: http://www.nabble.com/running-a-jms-client-with-mulitple-threads-tf2016632.html#a5543879
Sent from the ActiveMQ - User forum at Nabble.com.


Re: running a jms client with mulitple threads

Posted by James Strachan <ja...@gmail.com>.
If you are not using an IoC container to take care of your lifecycles
for you, you could just register a JVM ShutdownHook to close the pool

On 7/29/06, Paul French <pa...@frenchiesystems.com> wrote:
>
> I only want to close the pool when the client application shutsdown. The
> client application will be running on mulitple machines and possibly for
> days at a time and at some point each application will have to be shutdown.
> ActievMQ broker will continue to run on a separate machine.
>
> I was just pointing out my difficulty in shutting down the client
> application.
>
>
> --
> View this message in context: http://www.nabble.com/running-a-jms-client-with-mulitple-threads-tf2016632.html#a5551720
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: running a jms client with mulitple threads

Posted by Paul French <pa...@frenchiesystems.com>.
I only want to close the pool when the client application shutsdown. The
client application will be running on mulitple machines and possibly for
days at a time and at some point each application will have to be shutdown.
ActievMQ broker will continue to run on a separate machine.

I was just pointing out my difficulty in shutting down the client
application.


-- 
View this message in context: http://www.nabble.com/running-a-jms-client-with-mulitple-threads-tf2016632.html#a5551720
Sent from the ActiveMQ - User forum at Nabble.com.


Re: running a jms client with mulitple threads

Posted by James Strachan <ja...@gmail.com>.
Why do you want to stop the connection pool?

http://incubator.apache.org/activemq/how-do-i-use-jms-efficiently.html


On 7/28/06, Paul French <pa...@frenchiesystems.com> wrote:
>
> I have a work around but I'm wondering if anyone else has a better idea?
>
> I use a PooledConnectionfactory for my JMS connections.
>
> I start say 10 threads from my main thread all part of the same thread
> group. They send some JMS messages and then finish.
>
> I need to detect when all the threads have finshed so I can close the
> PooledConnectionFactory by calling stop() to release the system resources.
>
> The problem I have is the first JMS call within one of the new threads
> starts up the acivemq processes on the client (3 of them, a connection and 2
> schedulers) and they automatically become part of my ThreadGroup. These
> threads never die!! Hence even when all my threads stop I still have active
> activemq threads part of the threadgroup.
>
> I did a work around by calling start on the PooledConnectionFactory from
> within the main thread before I started my 10 threads. Then it is easy to
> check the threadgroup active count is zero before I call stop().
>
> Any better ideas since I'm not sure if I will always have the luxury of
> pre-starting the connection pool.
> --
> View this message in context: http://www.nabble.com/running-a-jms-client-with-mulitple-threads-tf2016632.html#a5543879
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/