5 Replies Latest reply on Apr 25, 2012 9:30 AM by tabish121

    MessageConsumer.receive() throwing InterruptedException

    ingrid_ingrid.olson

      When I interrupt a thread that is calling receive() on a MessageConsumer, a JMSException is thrown.  The cause of this is an InterruptedException.  In the catch block of the thrown JMSException, I then try calling close() the MessageConsumer.  Attempting to close the MessageConsumer throws another JMSException due to an InterruptedIOException that gets thrown  inside of the "this.transport.oneway(command)" line of the doAsyncSendPacket(Command command) call inside of the doClose() method inside of the close() method of the ActiveMQMessageConsumer class.

       

      The result of this is that the MessageConsumer does not close, so that when I try to resubscribe my MessageConsumer to a durable Topic, I get an error that the MessageConsumer is already in use for that subscription name and client ID.

      #AMQ-3529 (https://issues.apache.org/jira/browse/AMQ-3529) looks like it  addresses a similar issue, which has supposedly been fixed.  When I use the most recent snapshot of 5.6, though, I still encounter the same problem.  I am currently using the most recent stable release (FMB 5.5.1).

       

      Is this a bug or is just the expected behavior?   Based on #JMS_SPEC-66 (http://java.net/jira/browse/JMS_SPEC-66) it looks like the behavior of what ought to happen has not yet been defined.   If it is the expected behavior, are there any workarounds to closing a message consumer after interrupting a thread while in MessageConsumer.receive()?