Skip to content

kafka_deliveryAttempt header with initial value 2 in non-blocking retries #2464

@jgslima

Description

@jgslima

In what version(s) of Spring for Apache Kafka are you seeing this issue?
2.9.1

Describe the bug
It is about the value of the Header "kafka_deliveryAttempt" (KafkaHeaders.DELIVERY_ATTEMPT).
When used in combination with non-blocking retries, from the 2nd non-blocking attempt, it starts with the value 2 instead of 1.

Example: in a configuration with 2 blocking retries (Backoff with 2 maxAttempts) and a RetryTopicConfiguration with .maxAttempts(3), one would expect the value of the Headers in each listener invocation to be:

kafka_deliveryAttempt=1, retry_topic-attempts=null
kafka_deliveryAttempt=2, retry_topic-attempts=null
kafka_deliveryAttempt=3, retry_topic-attempts=null

kafka_deliveryAttempt=1, retry_topic-attempts=2
kafka_deliveryAttempt=2, retry_topic-attempts=2
kafka_deliveryAttempt=3, retry_topic-attempts=2

kafka_deliveryAttempt=1, retry_topic-attempts=3
kafka_deliveryAttempt=2, retry_topic-attempts=3
kafka_deliveryAttempt=3, retry_topic-attempts=3

But instead we have:

kafka_deliveryAttempt=1, retry_topic-attempts=null
kafka_deliveryAttempt=2, retry_topic-attempts=null
kafka_deliveryAttempt=3, retry_topic-attempts=null

kafka_deliveryAttempt=2, retry_topic-attempts=2
kafka_deliveryAttempt=2, retry_topic-attempts=2
kafka_deliveryAttempt=3, retry_topic-attempts=2

kafka_deliveryAttempt=2, retry_topic-attempts=3
kafka_deliveryAttempt=2, retry_topic-attempts=3
kafka_deliveryAttempt=3, retry_topic-attempts=3

To Reproduce
Please see above.

Expected behavior
Please see above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions