activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <>
Subject Re: how to safely delete a cms::MessageListener object
Date Thu, 15 Jan 2015 16:35:28 GMT
On 01/14/2015 08:01 PM, Steve Rice wrote:
> Since the onMessage() function runs in a separate thread, how do I safely
> delete a cms::MessageListener object in the main thread using C++11?  If the
> reply I am looking for never comes, I want to give up on listening for it
> and throw away this object.  But what if in the process of deleting this
> object in the main thread, the onMessage() function gets called in the
> separate thread?  In other words, how do I stop listening for messages and
> clean up safely from the main thread?
> Steve Rice
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at
The safest way is to close the consumer, then you know it won't dispatch 
any more message.  If you want to continue to use that consumer then you 
need to stop the session in order to ensure that no dispatches will 
occur at which point you can set the message listener to null on the 
consumer and then destroy your MessageListener.

Tim Bish
Sr Software Engineer | RedHat Inc. |
skype: tabish121 | twitter: @tabish121

View raw message