When we are using a container with concurrency greater than 1, and wish to pause all the child containers, can we pause directly using:
MessageListenerContainer mlc= registry.getListenerContainer(<id>);
mlc.pause();
Or do we have to cast it to a Concurrent Message Listener Container and pause each container individually?
Thanks in advance.
CodePudding user response:
If you're using @KafkaListener(id = "your-id",...) for your method, it will be registered as an instance of ConcurrentMessageListenerContainer. So when you call mlc.pause(), it actually is ConcurrentMessageListenerContainer#pause, you don't have to cast it (polymorphism).
With ConcurrentMessageListenerContainer#pause, it will delegate to all KafkaMessageListenerContainer#pauses inside it (for example: concurrency = 3, you will have 3 instances of KafkaMessageListenerContainer). You don't have to pause each container individually, mlc.pause() is enough.
