Consuming Kafka messages from an offset with KafkaEx

I have a working Elixir app consuming messages from my Kafka broker, it was really easy thanks to the excellent KafkaEx package.

The question I have revolves around reading from different offsets on a partition.

My GenConsumer is implemented like here https://hexdocs.pm/kafka_ex/KafkaEx.html#module-consumer-groups always reads the latest unread from the last committed offset, which is fine.

  1. While its reading the messages, it would be nice to know the offset position it is at, for performance monitoring, but the state is nil as its up to us to set.
  2. If I wanted to read from a given offset, I guess the KafkaEx.GenConsumer is no good for this? I would have to implement my own GenServer /GenStage with KafkaEx.fetch/KafkaEx.stream in?
4 Likes