0
votes

I am running a spring application using spring-Kafka for consumer applications. In Kafka listener, we have autostartup set using SpEL expression. We change this value at runtime to make this expression as false. KafkaListener stops consuming further messages when we change the property.

Question: Is this the correct way to stop polling for further records or should we use kafkaListenerEndpointRegistry and stop the service? What's the difference between these two?

Another one, if I have another application using the same consumer group will all the partitions get reassigned to that application?

1

1 Answers

3
votes

autoStartup is only considered once (during application context initialization). If true, the container will be started, if false, it will not.

Changing the property at runtime after initialization will not stop the container.

You have to use stop/start via the container registry to stop/start containers after the context is up and running).

If you have multiple instances in the same group, the partitions will be distributed across the instances; a partition can only be consumed by one consumer in the same group.