I have recently started working on Apache Kafka. One thing which I keep on seeing on various blogs is that multiple topics are configured to the same listener.
My question is, Is it a good practice to do so?
Let's say we are receiving 100 messages per sec on each topic. Message from each topic need different customization. And message from. Individual topics got to respective tables. Example: message from topic1 goes to topic_1
table.
It's a Spring Boot app that I'm working on. Also I would like to know what other challenges I might face going forward.
Update: Code sample
@KafkaListener(topics = "#{'${kafka-consumer.topics}'.split(',')}", groupId = "${kafka-consumer.groupId}")
public void consume(KafkaConsumer<String, String> record) {
int count = 0;
ConsumerRecords<String, String> records = record.poll(1000);
for (ConsumerRecord<String, String> data : records) {
System.out.println(data.value());
count++;
}
//record.listTopics()
if(count > 0){
record.commitAsync();
}
}