Client-side offset tracking and old messages #151
-
Hi! I'm trying to track offset on the client side and sometimes get old messages. I start like this:
and then
I expect that context.offset() always increments but sometimes I see batches of old messages (thousands) with smaller offsets passed to handle() and then suddenly everything gets OK. Am I missing something? |
Beta Was this translation helpful? Give feedback.
Answered by
acogoluegnes
Jul 4, 2022
Replies: 1 comment 3 replies
-
Can I expect that sequential calls of context.offset() in the context of handle() return the same value? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context#offset()
should return the (unique) offset of the deliveredMessage
. You're right, it should always return the same value in the context of a single tohandle
. It should increment in the next calls, under normal circumstances (no reconnection, etc).The behavior you're observing is not normal. Your code seems correct. Which versions of Erlang/RabbitMQ/Java client are you using? Can you provide the server logs and the client logs?
Are you able to reproduce this behavior?
There can be duplicated messages e.g. when the connection dies and the client recovers it, but this should not happen if your offset tracking is reliable and is updated for each message.