-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-3407 : Support KafkaHeaders.DELIVERY_ATTEMP for batch listeners. #3539
GH-3407 : Support KafkaHeaders.DELIVERY_ATTEMP for batch listeners. #3539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
...afka/src/main/java/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListener.java
Outdated
Show resolved
Hide resolved
...afka/src/main/java/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListener.java
Outdated
Show resolved
Hide resolved
...afka/src/main/java/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListener.java
Outdated
Show resolved
Hide resolved
...ava/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTest.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerTest.java
Outdated
Show resolved
Hide resolved
90bc27a
to
47f13e5
Compare
@artembilan thanks for your time and comments! |
...fka-docs/src/main/antora/modules/ROOT/pages/retrytopic/kafka-headers-for-batch-listener.adoc
Outdated
Show resolved
Hide resolved
spring-kafka-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc
Outdated
Show resolved
Hide resolved
...afka/src/main/java/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListener.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
@artembilan thanks for your time for looking into changes, again! 🙇♂️ Always thanks to read my code 🙇♂️ |
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/kafka/listener/DeliveryAttemptAwareRetryListenerIntegrationTests.java
Outdated
Show resolved
Hide resolved
@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_ATTEMPT
header from the receivedConsumerRecord
.It works well with the
SingleRecordListener
.However, it does not work well with the
BatchListener
even whencontainerProperties.setDeliveryAttemptHeader(true)
is set.If the
KafkaContainerListener
can include theKafkaHeaders.DELIVERY_ATTEMPT
header for eachConsumerRecord
with theBatchListener
, it will be more helpful to people who they expect.Modifications
DeliveryAttemptAwareRetryListener
class.DeliveryAttemptAwareRetryListener
.To Reviewer
With current
spring-kafka
codes, 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
DeliveryAttemptAwareRetryListener
is 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
ContainerFactory
andDeliveryAttemptAwareRetryListener
. also, they setDeliveryAttemptAwareRetryListener
asRetryListener
.Please refer to code below.
Result: