How can one read the last x messages from a topic with a reader?
Bogdan405 opened this issue · 6 comments
Bogdan405 commented
How can one read the last x messages from a topic with a reader?
mostafa commented
Hey @Bogdan405,
I haven't tested this before, but if you know the offset, you can set it using the ReaderConfig offset and the limit
in the consume
method to the number of messages you want to read.
Bogdan405 commented
Thank you, can I set the offset to the latest message somehow? Or is there a way to get the current offset without consuming all the messages?
mostafa commented
@Bogdan405
There is currently no explicit way to do it, unless you read a single message (limit=1
).
Bogdan405 commented
Ok, I will keep experimenting
mostafa commented
I'll close this issue, and feel free to re-open it if the issue is not resolved.
Manuel-Moya commented
@Bogdan405 , how did you solve your requirement? I am trying to get the last message as well.