跳到主要内容

在监听器容器上暂停和恢复分区

ChatGPT-4o-mini 中英对照 Pausing and Resuming Partitions on Listener Containers

自版本 2.7 起,您可以通过在监听器容器中使用 pausePartition(TopicPartition topicPartition)resumePartition(TopicPartition topicPartition) 方法来暂停和恢复分配给该消费者的特定分区的消费。暂停和恢复分别发生在 poll() 之前和之后,类似于 pause()resume() 方法。isPartitionPauseRequested() 方法如果请求了该分区的暂停,则返回 true。isPartitionPaused() 方法如果该分区已有效暂停,则返回 true。

此外,从版本 2.7 开始,ConsumerPartitionPausedEventConsumerPartitionResumedEvent 实例以容器作为 source 属性和 TopicPartition 实例进行发布。