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, the main
thread may decide that it has given up on receiving the reply and wants to
cleanup the objects that were set up to receive the reply.  It appears I can
set the message listener associated with the consumer to NULL (or close the
consumer), which will prevent an incoming reply from calling the onMessage()
function associated with message listener.  That stops the listening.  The
case I am concerned about is when the onMessage() function has begun
executing to process a reply, but has not yet reached a statement where I
can set a flag to indicate to the main thread that it is executing.  At that
moment, the main thread does not know that there is a concurrent execution
of onMessage() and may proceed with de-allocating objects used by
onMessage().  Perhaps this window of vulnerability can be closed by using
C++11 shared pointers, but that would require modifying the CMS code.

Steve Rice



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/how-to-safely-delete-a-cms-MessageListener-object-tp4689939p4689955.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to