activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Bertram <jbert...@redhat.com>
Subject Re: Artemis v2.2: ActiveMQIllegalStateException with core API
Date Thu, 24 Aug 2017 13:46:27 GMT
> What's the correct way to shut down a consumer process when using message
handlers?

I would do this:

  1) Invoke org.apache.activemq.artemis.api.core.client.ClientSession#stop
  2) Invoke org.apache.activemq.artemis.api.core.client.ClientConsumer#close


> How would disable receipt of new messages?

Invoke org.apache.activemq.artemis.api.core.client.ClientSession#stop


> Does Artemis API provide any mechanism for waiting until all received messages
have been acknowledged...

When org.apache.activemq.artemis.api.core.client.ClientConsumer#close is
invoked it will wait up to 10 seconds for the onMessage of the
MessageHandler to complete.

To be clear, if there are any unacknowledged messages when the session is
closed they will be canceled back to the queue for other consumers to
receive.


Justin

On Thu, Aug 24, 2017 at 3:33 AM, Marko Asplund <marko.asplund@gmail.com>
wrote:

> On Wed, 23 Aug 2017 20:05:35 GMT Justin Bertram wrote:
>
> > So I just looked at the code again and I totally missed the
> Thread.sleep()
> > in consumeMessage() which nullifies my previous theory.
>
> My actual consumer code closes the session when the process is shut down.
> But, I guess in some cases this could actually result in the race condition
> you described where a session gets closed before a message handler
> acknowledges the message it's processing.
>
> What's the correct way to shut down a consumer process when using message
> handlers?
> If I try to wait until all received messages get acknowledged this may
> never occur if there're always messages in the queue, right?
>
> From an API user perspective I'd expect to do something like the following:
> 1. disable receipt of any new messages
> 2. wait until all received messages get processed and acknowledged
> 3. close session
>
> How would disable receipt of new messages?
>
> Does Artemis API provide any mechanism for waiting until all received
> messages have been acknowledged or should I use something from
> java.util.concurrent?
>
> marko
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message