Pausing and Resuming the Consumer

如果您希望暂停消耗,但不导致分区重新平衡,则可以暂停并恢复使用者。这可以通过管理 Spring Cloud Stream 文档中的 绑定可视化和控制 中显示的绑定的生命周期,使用 State.PAUSEDState.RESUMED 来实现。

If you wish to suspend consumption but not cause a partition rebalance, you can pause and resume the consumer. This is facilitated by managing the binding lifecycle as shown in Binding visualization and control in the Spring Cloud Stream documentation, using State.PAUSED and State.RESUMED.

要恢复,您可以使用 ApplicationListener(或 @EventListener 方法)来接收 ListenerContainerIdleEvent 实例。发布事件的频率由 idleEventInterval 属性控制。

To resume, you can use an ApplicationListener (or @EventListener method) to receive ListenerContainerIdleEvent instances. The frequency at which events are published is controlled by the idleEventInterval property.