如何配置Kafka以重复未提交的偏移消息

如何配置Kafka以重复未提交的偏移消息

本文介绍了如何配置Kafka以重复未提交的偏移消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有关于我的主题的这些消息:

Suppose I have these messages on my topic:

[A, A, B, A, B]

我的应用程序成功处理了 A,但 B 引发了意外异常.我认为将 ackOnError 更改为 false 不会提交偏移量,因此侦听器会重复处理相同的消息,直到 Kafka 侦听器无异常地处理消息.我已将 enable.auto.commitackOnError 设置为 false 但侦听器仍在跳转到下一条消息,无论消息是 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?

推荐答案

您需要配置 SeekToCurrentErrorHandler 以重播失败.

You need to configure the SeekToCurrentErrorHandler to replay failures.

参见文档.

这篇关于如何配置Kafka以重复未提交的偏移消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:35