Re: how to safely delete a cms::MessageListener object

2015-01-16 Thread Steve Rice
Awesome. Thanks, Tim. Steve Rice -- View this message in context: http://activemq.2283324.n4.nabble.com/how-to-safely-delete-a-cms-MessageListener-object-tp4689939p4690062.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: how to safely delete a cms::MessageListener object

2015-01-16 Thread Timothy Bish
On 01/16/2015 12:09 PM, Steve Rice wrote: So if the thread wanting to shut down the Message Listening sets the message listener to NULL, the setMessageListener call will not return until there is no onMessage function in progress? And so, after the setMessageListener(NULL) call returns, it is sa

Re: how to safely delete a cms::MessageListener object

2015-01-16 Thread Steve Rice
So if the thread wanting to shut down the Message Listening sets the message listener to NULL, the setMessageListener call will not return until there is no onMessage function in progress? And so, after the setMessageListener(NULL) call returns, it is safe to delete the MessageListener object? S

Re: how to safely delete a cms::MessageListener object

2015-01-16 Thread Tim Bain
That sounds way better than what I'd proposed. On Fri, Jan 16, 2015 at 9:18 AM, Timothy Bish wrote: > On 01/15/2015 09:16 PM, artnaseef wrote: > >> How about the following instead? As Tim pointed out, the consumer close >> won't return until no more calls to onMessage are guaranteed. I believe

Re: how to safely delete a cms::MessageListener object

2015-01-16 Thread Timothy Bish
On 01/15/2015 09:16 PM, artnaseef wrote: How about the following instead? As Tim pointed out, the consumer close won't return until no more calls to onMessage are guaranteed. I believe that also means it won't return while onMessage() is actively being called. @Tim - can you confirm? It shou

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread artnaseef
How about the following instead? As Tim pointed out, the consumer close won't return until no more calls to onMessage are guaranteed. I believe that also means it won't return while onMessage() is actively being called. @Tim - can you confirm? If that's correct, the following should do the job

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread Steve Rice
Thanks. I considered the sleep idea and will probably go that route. Steve Rice -- View this message in context: http://activemq.2283324.n4.nabble.com/how-to-safely-delete-a-cms-MessageListener-object-tp4689939p4689997.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread Tim Bain
You could probably handle that problem in most cases by adding a flag that says whether onMessage() is currently running (increment on entry, decrement on exit) combined with a long enough sleep() call; it's a bit ham-fisted, but it should be good enough. Close the consumer (so you know that there

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread Steve Rice
Thanks for the suggestions. I have a request-and-reply mechanism, where the reply arrives asynchronously to a temporary queue, and a consumer has been set up to listen for that reply sent to the temporary queue. At some point, after waiting awhile to receive the reply and still not getting it, th

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread Timothy Bish
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. B

Re: how to safely delete a cms::MessageListener object

2015-01-15 Thread artnaseef
Good question. In java, we don't need to worry about the memory allocation - just the concurrency. While I don't know the answer, I'll give some input here. Have you looked through the CMS code? Some things that may work: * Closing the consumer; once the close() method returns, I would not exp