You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "binchen (Jira)" <ji...@apache.org> on 2022/09/28 11:24:00 UTC

[jira] [Commented] (ARTEMIS-3351) MessageConsumer gets stuck indefinitely when session is closed from management console

    [ https://issues.apache.org/jira/browse/ARTEMIS-3351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17610505#comment-17610505 ] 

binchen commented on ARTEMIS-3351:
----------------------------------

We encountered the same problem. By looking at the source code, we found that receive(timeout) or receiveNoWait() may not be implemented in accordance with the JMS specification. At present, our solution can only use the JTA transaction timeout way to interrupt it, look forward to subsequent improvements.

The JMS specification explains MessageConsumer.receive(timeout) as follows:
To limit the amount of time that the client blocks, use a timeout parameter with the receive method. *If no messages arrive by the end of the timeout, then the receive method returns.* The timeout parameter is expressed in milliseconds.
Example:
_// Wait up to 4 seconds for a message_ 
_Message stockMessage = receiver.receive(4000);_

> MessageConsumer gets stuck indefinitely when session is closed from management console
> --------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-3351
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3351
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.17.0
>         Environment: Using Artemis 2.17.0, out-of-the box installation, default instance, clean install.
>            Reporter: Costas Stergiou
>            Priority: Major
>
> When a session is closed from the Management console (_Sessions_ tab -> _Close_ button), the consumer never gets notified. 
> Bug is reproducible with JMS and Core. It happens if the consumer loops in a _receive(timeout)_ or _receiveNoWait()._ It also happens when the _setMessageListener()_ has been called for callback-style reception.
> To reproduce:
>  # create a consumer (JMS or Core)
>  # use a thread to loop indefinitely using _consumer.receive(1000);_
>  # create a producer, send messages, verify it all works 
>  # from the Management Console, kill/close the session corresponding to the consumer.
>  # The consumer.receive*() method never returns after the session is closed. If using the _setMessageListener_() no more callbacks occur when new messages arrive. No exception thrown whatsoever, nothing reported in _connection.setExceptionListener()_
> A quick look at the code show the thread waiting on this stack:
> {code:java}
> wait:-1, Object (java.lang)
> receive:267, ClientConsumerImpl (org.apache.activemq.artemis.core.client.impl)
> receiveImmediate:411, ClientConsumerImpl (org.apache.activemq.artemis.core.client.impl)
> getMessage:211, ActiveMQMessageConsumer (org.apache.activemq.artemis.jms.client)
> receiveNoWait:139, ActiveMQMessageConsumer (org.apache.activemq.artemis.jms.client)
> lambda$createConsumer$0:74, ActiveMQCommon (com.imagetrust.activemq)
> run:-1, ActiveMQCommon$$Lambda$15 (com.imagetrust.activemq)
> call:511, Executors$RunnableAdapter (java.util.concurrent)
> run:266, FutureTask (java.util.concurrent)
> runWorker:1149, ThreadPoolExecutor (java.util.concurrent)
> run:624, ThreadPoolExecutor$Worker (java.util.concurrent)
> run:748, Thread (java.lang) {code}
> Looks like _ClientConsumerImpl::receive_ waits indefinitely (or does an indefinite loop) in line 267:
> {code:java}
> try {
>    wait(toWait); <<< 
> } catch (InterruptedException e) {
>    throw new ActiveMQInterruptedException(e);
> } {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)