簡體   English   中英

在 Spring 引導中注入由 ConcurrentMessageListenerContainer 創建的所有 Kafka 消費者?

[英]Inject all Kafka Consumers created by a ConcurrentMessageListenerContainer in Spring Boot?

我們正在使用ConcurrentMessageListenerContainer來創建我們的 Kafka Consumer

使用ConcurrentMessageListenerContainer#concurrency屬性可以創建多個消費者。

是否有可能在 Spring Boot 應用程序中注入ConcurrentMessageListenerContainer創建的所有Consumer 或者是否有可能在ApplicationEvent之后以某種方式獲得它們?

為什么需要訪問底層的Consumer對象? 它們由容器管理。

消費者在消息偵聽器中作為參數可用,並包含在已發布的事件中,但不建議直接使用Consumer API,因為這樣的用法可能與容器的預期沖突。

可以使用被動 API,例如獲取訂閱主題的結束偏移量。

暫無
暫無

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

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