简体   繁体   English

卡夫卡生产者禁用

[英]Kafka producer disabling

I have an app that consumes one Kafka topic, doing things, and produces the result into two different topics.我有一个应用程序,它使用一个 Kafka 主题,执行操作,并将结果生成为两个不同的主题。

The tricky thing is that the outgoing topic may not exist yet and I need to have an opportunity to switch off the producer on demand by environment varieable.棘手的是,传出的主题可能还不存在,我需要有机会根据环境变量按需关闭生产者。

I can disable send() method this way, but at app startup it tries to connect to the topic to get metadata and spams:我可以通过这种方式禁用 send() 方法,但在应用程序启动时,它会尝试连接到主题以获取元数据和垃圾邮件:

Error while fetching metadata ... UNKNOWN_TOPIC_OR_PARTITION

Tried different producer-properties but with no luck.尝试了不同的生产者属性,但没有运气。 Also tried to annotate producer class with ConditionalOnProperty, but the bean is required by service class.还尝试使用 ConditionalOnProperty 注释生产者类,但服务类需要该 bean。

By default producers and consumers are started automatically.默认情况下,生产者和消费者是自动启动的。 You can disable it using auto-startup Consumer/Producer properties - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#_producer_properties .您可以使用auto-startup消费者/生产者属性禁用它 - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#_producer_properties

You can also start/stop bindings via actuator REST endpoints - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#binding_visualization_control您还可以通过执行器 REST 端点启动/停止绑定 - https://docs.spring.io/spring-cloud-stream/docs/3.1.5/reference/html/spring-cloud-stream.html#binding_visualization_control

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM