3

I am using Consumer.acknowledgeAsync() to ack messages in my Java service and was wondering what happens if the ack fails? Should I retry the operation a few times and discard my consumer when retries are exhausted?

I am counting the number of messages being processed for flow-control to limit memory usage.

1
  • It depends, right? If there were a one-size-fits-all solution, they wouldn't make you handle it yourself; they'd just, y'know, do it. Commented Dec 10, 2018 at 11:20

1 Answer 1

4

Usually, If message was not ack-ed successfully, after ackTimeout, the message will be redelivered from broker to consumer again. So here, most of the case, it is no need to retry.

maybe some handling like this is enough:

consumer.acknowledgeAsync(msgId)
    .thenAccept(consumer -> successHandlerMethod())
    .exceptionally(exception -> failHandlerMethod());
Sign up to request clarification or add additional context in comments.

1 Comment

Re-delivery is fine in my case (flow control) so I can just count the message as acknowledged and assume it will work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.