关闭kafka listener
时间: 2023-08-23 18:15:40 浏览: 99
关闭Kafka listener的方法可以通过以下步骤实现。首先,在监听的地方给监听加一个id,例如:`public static final String KAFKA_LISTENER_ID = "KAFKA_ID";`,然后在方法上使用`@KafkaListener`注解指定该id和监听的topic。接下来,需要注入`KafkaListenerEndpointRegistry`,例如:`@Autowired private KafkaListenerEndpointRegistry registry;`。最后,通过调用`registry.getListenerContainer(KAFKA_LISTENER_ID).stop()`方法来关闭Kafka listener。这样就可以暂时关闭Kafka的监听了。\[1\]
#### 引用[.reference_title]
- *1* [Kafka动态关闭、开启监听](https://blog.csdn.net/qq_20989105/article/details/87917738)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文