apache-kafkakafkajs

How can I selectively consume messages from a topic in kafkajs?


Let's say I have the offset and partition of specific messages in a kafkajs topic. How can I attach a consumer to this topic and consume only these specific messages? For example, if I have the offset and partition of a message in a topic, I would like to consume only that message, and no other messages. Is this possible?


Solution

  • You can seek a consumer to a partition+offset, then break the consumer loop when you get that one event, yes.