Reputation: 564
what is the difference in specifying group at the consumer
spring.kafka.consumer.group-id
vs specifying at the @KafkaListener?
@KafkaListener(topic="test", group = "test-grp")
Upvotes: 6
Views: 10517
Reputation: 174504
See the javadocs for the group
property; it has nothing to do with the kafka group.id
...
/**
* If provided, the listener container for this listener will be added to a bean
* with this value as its name, of type {@code Collection<MessageListenerContainer>}.
* This allows, for example, iteration over the collection to start/stop a subset
* of containers.
* @return the bean name for the group.
*/
This has been renamed containerGroup
in 1.3/2.0.
Those release versions also provide...
/**
* Override the {@code group.id} property for the consumer factory with this value
* for this listener only.
* @return the group id.
* @since 1.3
*/
String groupId() default "";
/**
* When {@link #groupId() groupId} is not provided, use the {@link #id() id} (if
* provided) as the {@code group.id} property for the consumer. Set to false, to use
* the {@code group.id} from the consumer factory.
* @return false to disable.
* @since 1.3
*/
boolean idIsGroup() default true;
Previously, you needed a container factory/consumer factory for each listener; these allow you to use one factory instance and override the group.id
.
Upvotes: 4