Reputation: 85
@KafkaListener(containerFactory = "syliusKafkaListenerContainerFactory",
topics = "#{__listener.getTopics()}",
groupId = "${tenantprop.kafkaConfigProperties.listenerGroupId}")
public void listenEvent(@Payload SyliusEvent syliusEvent,
@Header(KafkaHeaders.RECEIVED_TOPIC) String topic, Acknowledgment acknowledgment)
throws Exception {}
In the above method, this listener is getting called for various country and with different topic.Everything is same for all the countries except containerFactory.
So rather to create different listener for every country, is there any way to change containerFactory for each country keeping same listenEvent method.i.e, not to create different listener for each country.
Also,Any workaround if data is coming from one country is huge which result in blockage of complete listener and no other country can put data ?
Looked through internet but doesn't found anything concrete.Any help will be appreciated.
Upvotes: 1
Views: 557
Reputation: 121462
No, there is no way to have a single @KafkaListener
for different container factories. The final consumer listener is very tied to the factory its container is based on. So, you really have to provide separate @KafkaListener
for each containerFactory
you have in your configuration. You may consider to look into Kafka Streams to join initial data from different consumers to a single topic in the end. Then you indeed would just have one @KafkaListener
on one topic against one containerFactory
.
Upvotes: 2