ActiveMQ: How to retain inflight messages post consumer restart

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ: How to retain inflight messages post consumer restart

khandelwalanuj
Hi,

Using Topics with durable subscribers.

I am using client acknowledgement for my durable consumer. I acknowledge the message after every nth message.  Which takes care of acknowledging all the messages received before that.

I am facing an issue where consumer receives some messages (<n) so consumer has not acknowledged it yet. so those are marked as inflight in the broker. Now if consumer goes down, and come up again, consumer does not receives those messages back. In Jconsole I can see that those messages are lost.

Ideally If I haven't acknowledged the message, it should stay within the broker and should be received back if consumer is polling again.

Thanks,
Anuj
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ: How to retain inflight messages post consumer restart

Tim Bain
Can you please describe what you see in JConsole that tells you that the
messages are lost? (And can you please define the word "lost" as you're
using it here? Do you mean that they are acked - but not by your code - or
that they end up in the DLQ or something else?)

When your consumer disconnects, is this a graceful exit or a hard shutdown
(kill -9)? And when the consumer reconnects, what behavior is seen?

Tim

On Jun 5, 2017 7:30 AM, "khandelwalanuj" <[hidden email]>
wrote:

> Hi,
>
> Using Topics with durable subscribers.
>
> I am using client acknowledgement for my durable consumer. I acknowledge
> the
> message after every nth message.  Which takes care of acknowledging all the
> messages received before that.
>
> I am facing an issue where consumer receives some messages (<n) so consumer
> has not acknowledged it yet. so those are marked as inflight in the broker.
> Now if consumer goes down, and come up again, consumer does not receives
> those messages back. In Jconsole I can see that those messages are lost.
>
> Ideally If I haven't acknowledged the message, it should stay within the
> broker and should be received back if consumer is polling again.
>
> Thanks,
> Anuj
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/ActiveMQ-How-to-retain-inflight-messages-post-
> consumer-restart-tp4727027.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ: How to retain inflight messages post consumer restart

khandelwalanuj
My bad Tim.

I was normally shutting down the consumer instead of kill -9

It works fine with kill -9

Thanks,
Anuj
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ: How to retain inflight messages post consumer restart

Tim Bain
That sounds like the remaining inflight messages are getting acknowledged
during the process of shutting down gracefully; even though your consumer
never received them. Is that accurate? If so, that still sounds like a bug.

On Jun 6, 2017 3:34 AM, "khandelwalanuj" <[hidden email]>
wrote:

> My bad Tim.
>
> I was normally shutting down the consumer instead of kill -9
>
> It works fine with kill -9
>
> Thanks,
> Anuj
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/ActiveMQ-How-to-retain-inflight-messages-post-consumer-restart-
> tp4727027p4727070.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ: How to retain inflight messages post consumer restart

khandelwalanuj
> That sounds like the remaining inflight messages are getting acknowledged
> during the process of shutting down gracefully; even though your consumer
> never received them. Is that accurate? If so, that still sounds like a bug.

My durable consumer received them in client ack mode and didn't acknowledge them. So those messages are getting lost(Getting lost mean the consumer won't get them back when it come back online) if I gracefully shutdown the consumer. In my case gracefully shutdown means I will unsubscribe the durable consumer from the topic during shutdown.

If I don't unsubscribe the subscription, the broker mark the consumer as inactive durable subscriber and the consumer will get the messages again when it subscribe again.

That's an expected behavior I think.

Thanks,
Anuj
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ: How to retain inflight messages post consumer restart

Tim Bain
Unsubscribing a topic consumer means that the broker should discard all
messages for that consumer, and not retain any future messages for it. If
the consumer later subscribes again, that is a new subscription that starts
at that time, so only messages sent after that point will be delivered to
the consumer. Messages are not being lost; rather, your consumer is saying
that it doesn't want them.

The behavior you describe sounds like expected behavior in all three cases
you described (hard kill, graceful shutdown with unsubscription, and
graceful shutdown without unsubscription).

Tim

On Jun 6, 2017 11:16 PM, "khandelwalanuj" <[hidden email]>
wrote:

> > That sounds like the remaining inflight messages are getting acknowledged
> > during the process of shutting down gracefully; even though your consumer
> > never received them. Is that accurate? If so, that still sounds like a
> > bug.
>
> My durable consumer received them in client ack mode and didn't acknowledge
> them. So those messages are getting lost(Getting lost mean the consumer
> won't get them back when it come back online) if I gracefully shutdown the
> consumer. In my case gracefully shutdown means I will unsubscribe the
> durable consumer from the topic during shutdown.
>
> If I don't unsubscribe the subscription, the broker mark the consumer as
> inactive durable subscriber and the consumer will get the messages again
> when it subscribe again.
>
> That's an expected behavior I think.
>
> Thanks,
> Anuj
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/ActiveMQ-How-to-retain-inflight-messages-post-consumer-restart-
> tp4727027p4727134.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>