使用 KakfaIO 从给定的偏移量开始 [英] start at a given offset with KakfaIO

查看:26
本文介绍了使用 KakfaIO 从给定的偏移量开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 KafkaIO.read() 并且我想从特定偏移量开始消费.

I'm using KafkaIO.read() and I'd like to start consuming from a specific offset.

在某些时候,曾经有一个 KafkaIO.read().withStartFromCheckpointMark() 方法来做到这一点.

At some point there used to be a KafkaIO.read().withStartFromCheckpointMark() method to do that.

我从文档 有一种方法可以通过:

I see from the documentation that there is a way via:

由runner提供的KafkaCheckpointMark;

KafkaCheckpointMark provided by runner;

我该怎么做?

谢谢

推荐答案

没有直接支持,但有几个选项:

There is no direct support, but there are couple of options:

  • withStartReadTime() 可能更适合.
  • 您可以创建一个 group.id 并在该组中提交偏移量.当您在 KafkaConsumer 配置中设置 group.id 时,KafkaIO 默认从为该组提交的偏移量中恢复.您还可以选择在 KafkaConsumer 中启用 auto.commit.请参阅 JavaDoc 中的高级 Kafka 配置".
  • withStartReadTime() might be better suited.
  • You can create a group.id and commit offsets in that group. When you set group.id in KafkaConsumer config, KafkaIO defaults to resuming from offsets committed for the group. You can also chose to enable auto.commit in KafkaConsumer. See 'Advanced Kafka Configuration' in JavaDoc.

这篇关于使用 KakfaIO 从给定的偏移量开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆