so, you're seeing this when you close the consumer? Perhaps the server consumer has been closed.. and your client is issuing an ack on the message but the consumer had already redelivered the messages when the disconnect event happened?
If that's the case the message could be ignored.. you could/should stop the client properly before stopping the server perhaps? if you replicate this issue on an example that would help a lot.. because so far I can only guess possible cases. On Thu, Aug 24, 2017 at 9:46 AM, Justin Bertram <[email protected]> wrote: >> 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 <[email protected]> > 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 >> -- Clebert Suconic
