简体   繁体   English

如何停止 @Bean 注释的 Kstream kafka 消费者并继续运行 spring-boot 应用程序

[英]How to stop a @Bean annotated Kstream kafka consumer and continue to run spring-boot application

I have multiple @Bean annotated Kstream, kafka consumers in same class, once a particular message (K,V) pair is consumed by all consumers, I need to stop all the consumer and execute a separate piece of code.The //comment part is what I need.我有多个@Bean注释的Kstream,同一个class中的kafka消费者,一旦所有消费者都消费了特定的消息(K,V)对,我需要停止所有消费者并执行一段单独的代码。 //comment部分是我需要的。 Below is pseudo-code for one of the consumers:以下是其中一位消费者的伪代码:

 @Bean
 public KStream<KEY, VALUE> ssStreams(StreamsBuilder builder) {



        KStream<KEY, VALUE> memberKStream = builder.stream(topicClass.getTopicName());

            KStream stream = memberKStream.map((key, value) -> {
                log.info("Consuming key  :::" + key.toString());


                if(value.getItem ='X' )
                {
                    // need to stop this consumer as soon as this condition is true
                   // jump the application to different class of project 

                }            

           }

}

Thing I have tried:我尝试过的事情:
1. Creating a exception and handling via DeserializationExceptionHandler. 1.通过DeserializationExceptionHandler创建异常并处理。

You should stop Kafka listener container您应该停止 Kafka 侦听器容器

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

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