簡體   English   中英

如何停止 @Bean 注釋的 Kstream kafka 消費者並繼續運行 spring-boot 應用程序

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

我有多個@Bean注釋的Kstream,同一個class中的kafka消費者,一旦所有消費者都消費了特定的消息(K,V)對,我需要停止所有消費者並執行一段單獨的代碼。 //comment部分是我需要的。 以下是其中一位消費者的偽代碼:

 @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 

                }            

           }

}

我嘗試過的事情:
1.通過DeserializationExceptionHandler創建異常並處理。

您應該停止 Kafka 偵聽器容器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM