Home > front end >  Inject all Kafka Consumers created by a ConcurrentMessageListenerContainer in Spring Boot?
Inject all Kafka Consumers created by a ConcurrentMessageListenerContainer in Spring Boot?

Time:02-09

We are using the ConcurrentMessageListenerContainer to create our Kafka Consumers.

With the ConcurrentMessageListenerContainer#concurrency property it is possible to create multiple consumers.

Is it possible in a Spring Boot application to inject all Consumers created by the ConcurrentMessageListenerContainer? Or is it possible to obtain them somehow after an ApplicationEvent?

CodePudding user response:

Why do you need access to the underlying Consumer objects? They are managed by the container.

The consumer is available as a parameter in the message listener and is included in published events, but using the Consumer API directly is not recommended because such usage might conflict with the container's expectations.

It's ok to use passive APIs, such as getting the end offsets of subscribed topics.

  •  Tags:  
  • Related