| 1. |
Is It Possible To Get The Message Offset After Producing? |
|
Answer» You cannot do that from a class that behaves as a producer like in most queue systems, its role is to fire and forget the messages. The broker will do the rest of the work like appropriate metadata handling with id’s, offsets, etc. As a consumer of the MESSAGE, you can get the OFFSET from a Kafka broker. If you gaze in the SimpleConsumer class, you will notice it fetches MultiFetchResponse OBJECTS that include offsets as a list. In ADDITION to that, when you iterate the Kafka Message, you will have MessageAndOffset objects that include both, the offset and the message SENT. You cannot do that from a class that behaves as a producer like in most queue systems, its role is to fire and forget the messages. The broker will do the rest of the work like appropriate metadata handling with id’s, offsets, etc. As a consumer of the message, you can get the offset from a Kafka broker. If you gaze in the SimpleConsumer class, you will notice it fetches MultiFetchResponse objects that include offsets as a list. In addition to that, when you iterate the Kafka Message, you will have MessageAndOffset objects that include both, the offset and the message sent. |
|