Apache Kafka - 如何等待订阅完成
Apache Kafka - How to wait for subscription to finish
我正在使用 Kafka 2.1.0 并希望在订阅完成后发布一条消息。生产者有没有办法知道是否发生了订阅,然后发布消息?否则我每次都会丢失第一条消息。
来自 https://kafka.apache.org/documentation.html#newconsumerconfigs、auto.offset.reset
状态:
What to do when there is no initial offset in Kafka or if the current
offset does not exist any more on the server (e.g. because that data
has been deleted):
earliest: automatically reset the offset to the earliest offset
latest: automatically reset the offset to the latest offset
none: throw exception to the consumer if no previous offset is found
for the consumer's group
anything else: throw exception to the consumer.
auto.offset.reset
的默认值为 latest
。为了确保您的消费者不会丢失第一条记录,您需要将 auto.offset.reset
设置为 earliest
。
我正在使用 Kafka 2.1.0 并希望在订阅完成后发布一条消息。生产者有没有办法知道是否发生了订阅,然后发布消息?否则我每次都会丢失第一条消息。
来自 https://kafka.apache.org/documentation.html#newconsumerconfigs、auto.offset.reset
状态:
What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):
earliest: automatically reset the offset to the earliest offset
latest: automatically reset the offset to the latest offset
none: throw exception to the consumer if no previous offset is found for the consumer's group
anything else: throw exception to the consumer.
auto.offset.reset
的默认值为 latest
。为了确保您的消费者不会丢失第一条记录,您需要将 auto.offset.reset
设置为 earliest
。