You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by LiXiao2007 <Li...@gmail.com> on 2007/02/27 03:34:13 UTC

One connection for multiple sessions or one connection for each session

I would like to write a program with multiple threads. Each thread will
subscribe same mesage queue. There are two ways to do that.
1. Each thread has its own connection and session to the queue.
2. All the threads share same connection and each thread has its own
session.

I don't know which way is better. Any help is greatly appreciated.


-- 
View this message in context: http://www.nabble.com/One-connection-for-multiple-sessions-or-one-connection-for-each-session-tf3297775s2354.html#a9174052
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: One connection for multiple sessions or one connection for each session

Posted by James Strachan <ja...@gmail.com>.
On 2/27/07, LiXiao2007 <Li...@gmail.com> wrote:
>
> I would like to write a program with multiple threads. Each thread will
> subscribe same mesage queue. There are two ways to do that.
> 1. Each thread has its own connection and session to the queue.
> 2. All the threads share same connection and each thread has its own
> session.
>
> I don't know which way is better. Any help is greatly appreciated.

You generally only need one connection; just make sure you have many
sessions (typically one per consumer is the best concurrency).

Some folks have found cases when doing lots of durable publishing that
more than one connection can help (maybe one connection for producing
messages is sometimes slightly faster), but for consuming, generally
only one connection is needed.
-- 

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