How to configure Kafka to repeat uncommitted offse

2019-08-30 22:19发布

问题:

Suppose I have these messages on my topic:

[A, A, B, A, B]

A is processed successfully by my application, but B throws an unexpected exception. I thought changing ackOnError to false would not commit offset and thus the listener would repeat processing the same message until Kafka listener process the message without exceptions. I have set enable.auto.commit and ackOnError to false but the listener is still jumping to next message, doesn't matter if message is A or B.

How can I accomplish this desired behavior to keep my listener trying to process same message until it succeeds without exceptions?

回答1:

You need to configure the SeekToCurrentErrorHandler to replay failures.

See the documentation.