Fetch message with specified key using Kafka Listener vs Kafka Consumer

Viewed 249

I use a SpringBoot App to produce or consume/listen to Kafka messages.

I produce a message in the topic and consume/listen to the specific message by comparing the messageKey and then send the consumed message for further processing.

I am stuck with what approach will be better suited to my requirement to get specific message i.e. Kafka Listener or Kafka Consumer what ?

1 Answers

KafkaListener is a Spring specific concept that wraps the Kafka Consumer API.

There is no way to get a message by a particular offset given the key. You must calculate the partition, then scan the entire offset

Related