0

I am using a KafkaListener in SpringBoot. I have enabled BatchListener. I access the list of messages(List messages) from the first index till last. My question is - does the message at 0th index means that this message has been pushed before messages at indexes >= 1 ?

Also, the header RECEIVED_TIMESTAMP will be less for messages at lower indexes?

Trayambak Kumar
  • 113
  • 1
  • 9
  • Have you done any prior research, like read questions such as https://stackoverflow.com/questions/42691095/how-can-i-consume-a-data-sequentiallyin-order-of-their-time-stamp-from-a-multi ... or well the kafka documentation itself? – GhostCat Apr 26 '21 at 08:40

1 Answers1

0

My question is - does the message at 0th index means that this message has been pushed before messages at indexes >= 1 ?

Yes, Kafka guarantees the order only within a partition, not between them. From what I understand, this implies the messages are ordered by a customer subscribed to only a single partition regardless of whether BatchListener is used or not.

Also, the header RECEIVED_TIMESTAMP will be less for messages at lower indexes?

Due to the characteristic of BatchListener I am afraid the RECEIVED_TIMESTAMP will be the same for all the messages in the list.

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
  • So, if I don't commit and process the messages again, the RECEIVED_TIMESTAMP will be the same or it will change? – Trayambak Kumar Apr 26 '21 at 08:45
  • The RECEIVED_TIMESTAMP is the value of the `timestamp` in the `ConsumerRecord`; with a batch listener it is a `List` where the position in the list matches the position of the value in the list. – Gary Russell Apr 26 '21 at 13:47