手动设置kafka group id的offset

Manually set offset for kafka group id

我已经使用 Confluent 平台 (v3.2.0) 设置了我的 kafka 平台。

我的 consumers/producers - 应用程序是使用 NuGet 包“Confluent-Kafka”在 C# 中编写的,以便 add/get 数据到我的 kafka 流。

我想知道是否可以为主题的特定消费者组 ID 设置偏移量,以便具有该组 ID "rollback" 的消费者到我设置的偏移量?

我的想法是能够在我的消费者应用程序之外执行此操作,首选在我需要 build 的管理员-ui 中。我只需要知道如何与kafka平台进行通信即可。这可以使用 cli 命令或休息来完成 api?

当你从协调员那里得到分配时你可以。在此处查看最后一条消息:

https://github.com/confluentinc/confluent-kafka-dotnet/issues/141 使用当前的 API,您不能在分区中跳转或返回,您将不得不再次 unsubscribe/subscribe,但您可以轻松地将其添加到您的代码中

在 Apache Kafka 0.11(Confluent 平台 v3.3)中,bin/kafka-consumer-groups 命令行工具有新选项允许为消费者组重置偏移量。您可以根据数字偏移量或时间设置偏移量。您还可以进行相对偏移量调整,例如后退 100 条消息或后退 5 分钟。

https://cwiki.apache.org/confluence/display/KAFKA/KIP-122%3A+Add+Reset+Consumer+Group+Offsets+tooling

--reset-offsets                         Reset offsets of consumer group.
                                      Supports one consumer group at the
                                      time, and instances should be
                                      inactive
                                    Has 3 execution options: (default) to
                                      plan which offsets to reset, --
                                      execute to execute the reset-offsets
                                      process, and --export to export the
                                      results to a CSV format.
                                    Has the following scenarios to choose:
                                      --to-datetime, --by-period, --to-
                                      earliest, --to-latest, --shift-by, --
                                      from-file, --to-current. One
                                      scenario must be choose
                                    To define the scope use: --all-topics
                                      or --topic. . One scope must be
                                      choose, unless you use '--from-file'
                                      scenario