【问题标题】:Pause message consumption and resume after time interval暂停消息消费并在时间间隔后恢复
【发布时间】:2022-02-02 22:03:29
【问题描述】:

我们正在使用 spring-cloud-stream 来处理 kafka。而且我需要在消费者从单个主题获取数据之间添加一些间隔。 batch-node 已设置为 true , fetch-max-wait、fetch-min-size、max-poll-records 也已调整。

我应该用 idleEventInterval 做点什么,还是方法不对?

【问题讨论】:

    标签: apache-kafka spring-cloud-stream spring-cloud-stream-binder-kafka


    【解决方案1】:

    您可以根据需要暂停/恢复容器(避免重新平衡)。

    https://docs.spring.io/spring-cloud-stream/docs/3.2.1/reference/html/spring-cloud-stream.html#binding_visualization_control

    从 3.1 版开始,我们公开了org.springframework.cloud.stream.binding.BindingsLifecycleController,它被注册为 bean,一旦注入就可以用来控制单个绑定的生命周期

    如果你只想延迟一小段时间,你可以设置容器的idleBetweenPolls属性,使用ListenerContainerCustomizer bean。

    【讨论】:

      猜你喜欢
      • 2018-06-10
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多