Getting the last message sent to a kafka topic

后端 未结 2 1813
执念已碎
执念已碎 2021-01-06 13:01

I\'m new to Kafka and working on a prototype to connect a proprietary streaming service into Kafka.

I\'m looking to get the key of the last message sent on a topic a

2条回答
  •  青春惊慌失措
    2021-01-06 13:53

    The problem is on line final long offset = consumer.committed(partition).offset(), as link api refers committed method is to get the last committed offset for the given partition, i.e: the last offset your consumer tell kafka server that it had already read. So, definitely you will got messages replayed, because you always read from specific offset. As I think I only have to remove the first for block.

提交回复
热议问题