Reputation: 1727
I'm using spring-kafka-2.2.7.RELEASE and trying to create a consumer using @KafkaListener at method level in conjunction with ConcurrentKafkaListenerContainerFactory. As per my understanding, this would create a ConcurrentMessageListenerContainer.
Is there an interceptor to intercept this container creation so that I can inject my custom logic to build groupId?
If I have two different methods using @KafkaListener to consumer two different topics, would it create two ConcurrentMessageListenerContainers?
Upvotes: 0
Views: 362
Reputation: 174729
If you have @KafkaListener(id = "foo", ..., autoStartup = "false")
you can auto wire the KafkaListenerEndpointRegistry
, and then...
registry.getListenerContainer("foo").getContainerProperties().setGroupId(...);
registry.getListenerContainer("foo").start();
However, you can simply use
@KafkaListener(... groupId "${some.property}")
or
@KafkaListener(... groupId "#{someSpelExpression}")
if all you want to do is set the group id.
Upvotes: 2