title: The right place to call stop() for MessageListeners and temporarily pause a connection's delivery of incoming messages.(JMSCC0012..)?
body: <p>As I can see in JMS specification connection.stop() can't be called from onMessage() for asynchronous MessageListener. 
  <strong>Could you please advise the right place to call connection.stop() to suspend delivery of incoming messages</strong> and don't get exception: <em>"JMSCC0012: The method 'stop()' may not be called from a message Listener."</em> <strong>and automatically resume the connection after some event?</strong> What the best practices of using connection.stop()?</p>
  
  <blockquote>
    <p><strong>From JMS 2.0 spec:</strong></p>
    
    <p>6.1.5. Pausing delivery of incoming messages  If any message listeners are running when stop is invoked, stop must wait until all of them
    have returned before it may return. While these message listeners are
    completing, they must have the full services of the connection
    available to them. A message listener must not attempt to stop its own
    connection as this would lead to deadlock. The JMS provider must
    detect this and throw a javax.jms.IllegalStateException. </p>
    
    <p><strong>From jms 1.1:</strong></p>
    
    <p>4.3.4 Pausing Delivery of Incoming Messages  If MessageListeners are running when stop is invoked, stop must wait until all of them have
    returned before it may return. While these MessageListeners are
    completing, they must have the full services of the connection
    available to them.</p>
  </blockquote>