GH-3407 : Support KafkaHeaders.DELIVERY_ATTEMP for batch listeners.#3539
Conversation
artembilan
left a comment
There was a problem hiding this comment.
I see now how this makes sense.
Thank you for fixing it!
Please, consider to mention a new feature in the docs, including a short entry with a link into target doc in the whats-new.adoc.
90bc27a to
47f13e5
Compare
|
@artembilan thanks for your time and comments! |
|
@artembilan thanks for your time for looking into changes, again! 🙇♂️ Always thanks to read my code 🙇♂️ |
|
@artembilan , It's my bad! |
|
Thank you, @chickenchickenlove , again for contribution! Please, take a look into this article about commit messages: https://cbea.ms/git-commit/.
Now imaging time is passing and we don't have contacts with you to remind us whatever was done in that commit years ago. |
|
Thanks for your time 🙇♂️ |
Motivation:
The developer expects to get the
KafkaHeaders.DELIVERY_ATTEMPTheader from the receivedConsumerRecord.It works well with the
SingleRecordListener.However, it does not work well with the
BatchListenereven whencontainerProperties.setDeliveryAttemptHeader(true)is set.If the
KafkaContainerListenercan include theKafkaHeaders.DELIVERY_ATTEMPTheader for eachConsumerRecordwith theBatchListener, it will be more helpful to people who they expect.Modifications
DeliveryAttemptAwareRetryListenerclass.DeliveryAttemptAwareRetryListener.To Reviewer
With current
spring-kafkacodes, it is hard to integrate it toFailedRecordTracker.By the way, the function
ErrorHandlingUtils.retryBatch()has deliveryAttempt count as their local scope and has same reference forConsumerRecord.Thus, the
DeliveryAttemptAwareRetryListeneris easier way to achieve the goal.Because, in each fail to invocation,
ErrorHandlingUtils.retryBatch()callslisteners.forEach(listener -> listener.failedDelivery(records, thrownException, attempt).If the developer want to use this feature, they should create
ContainerFactoryandDeliveryAttemptAwareRetryListener. also, they setDeliveryAttemptAwareRetryListenerasRetryListener.Please refer to code below.
Result: