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 expect to receive any more messages * Closing the session or connection for the consumer (also expecting no more messages after close() completes) * Set a new message listener on the consumer (expecting no more messages on the old after the new is replaced) By the way, frequently creating and removing consumers can get expensive with ActiveMQ, especially in a network of brokers. So, I recommend revisiting the design to see if there's a way to avoid doing so. For example, if waiting for responses on a shared queue using correlation IDs, a good approach is to instead have a queue dedicated to each server, have one permanent consumer on each server, and have a register-and-dispatch from that consumer to the internal recipient. Hope this helps. -- View this message in context: http://activemq.2283324.n4.nabble.com/how-to-safely-delete-a-cms-MessageListener-object-tp4689939p4689951.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.