如何从应用程序外部停止 Kafka Listener bean?

How to stop the Kafka Listener beans from outside the application?

如果服务器上有 Kafka 消费者 运行,是否可以通过 REST 服务等有选择地停止来自应用程序外部的侦听器 bean??

假设您正在使用 spring-kafka(您已标记),是的;参见 the documentation

您可以使用 KafkaListenerEndpointRegistry.

启动和停止所有或单个侦听器