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: 
http://activemq.2283324.n4.nabble.com/how-to-safely-delete-a-cms-MessageListener-object-tp4689939.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

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.
tim.b...@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply via email to