activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <>
Subject Re: ActiveMQ-CPP Threading/Reconnect Questions...
Date Wed, 20 Oct 2010 13:16:10 GMT
On Tue, 2010-10-19 at 21:14 -0700, jim_m2m wrote:
> My question is in 2 parts:
> 1. Reconnection...
> 1a. I can define the topic using failover queues, in which case calls to
> connection->start() or producer->send() block until the broker is available,
> which is not functionality that I like.  

You can set a timeout option on the failover transport and the producer
send operation will throw an exception after the defined timeout.  At
that point however you should treat the connection as failed.

> 1b. The other option is to not use failover, in which case the calls throw
> exceptions and I have to handle the reconnect on m own.


> 1c. In both cases, some objects may have been created, ie sessions,
> producers, and consumers.  If a connection is lost, are these objects still
> valid?  Or do I need to tear them all down and recreate them once the
> connection is restored.

At any point when an exception is thrown from the CMS objects you should
treat the Connection as failed as you don't know what the state of the
underlying resources are anymore.  All CMS resources should be destroyed
and recreated.

> 2. Threading...
> 2a. The documentation notes that the session is a single thread, what does
> this mean for performance?  

Messages are dispatched from a session using a single thread.  If you
have multiple consumers on a session the messages are delivered by that
single thread, you should use multiple sessions if you don't want this

> 2b. If my application has a producer and a consumer on different queues, is
> it best to have individual sessions for each, or should I be able to keep
> reusing the one session?

In general its good practice to have a session for each however it will
work to have only one session.


Tim Bish

Open Source Integration:

Follow me on Twitter:
My Blog:

View raw message