据我了解码织广播的最佳方式(即每个消费者都会收到所有消息) 就是给每个消费者它自己的消费者组ID。
问题在于“如果组中的所有消费者都离开该组,则该组将自动销毁
”
(来源:https://jaceklaskowski.gitbooks.io/apache-kafka/kafka-properties-group-id.html)
这意味着如果我的消费者将带有键 groupId,topicName,partitionNumber
的相应条目向下移动到 __consumer_offsets
将被删除,这意味着当消费者再次启动时,使用相同的组ID,它将无法读取在其关闭时发送的消息。
有人知道这个问题的解决办法吗?
最佳答案
组被自动销毁
并不意味着有关组的全部信息消失。我认为这与保存在内存中的数据有关。有关 offset
的信息不会从 __consumer_offsets
中删除。根据 offsets.retention.mines
属性的值,(代理属性)旧偏移量将被删除。默认 7 天(10080 分钟)
在 Apache Kafka 文档中,您可以找到有关 offsets.retention.months
属性 brokers configs 的信息。
offsets.retention.minutes - After a consumer group loses all its consumers (i.e. becomes empty) its offsets will be kept for this retention period before getting discarded. For standalone consumers (using manual assignment), offsets will be expired after the time of last commit plus this retention period.
这意味着,如果在 offsets.retention.months
分钟内没有来自特定组的消费者连接,则有关 offset 的信息将被删除。
关于java - 卡夫卡广播。如果组中唯一的消费者出现故障,如何知道消费者组的读取偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54215578/