user10254887
user10254887

Reputation: 88

Pausing entire container when concurrency is greater than 1

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.

Upvotes: 0

Views: 209

Answers (1)

Linh Vu
Linh Vu

Reputation: 970

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.

Upvotes: 2

Related Questions