Skip to content

fix(core): correct retry semantics for consumer maxAttempts configuration#3186

Open
vishwasio wants to merge 1 commit intospring-cloud:mainfrom
vishwasio:fix/kafka-consumer-max-attempts-retry
Open

fix(core): correct retry semantics for consumer maxAttempts configuration#3186
vishwasio wants to merge 1 commit intospring-cloud:mainfrom
vishwasio:fix/kafka-consumer-max-attempts-retry

Conversation

@vishwasio
Copy link

Fix off-by-one retry behavior for maxAttempts configuration.

Currently the retry policy is configured as:

maxRetries(properties.getMaxAttempts())

However maxRetries represents the number of retries, while
maxAttempts represents the total number of delivery attempts.

Example:

maxAttempts = 2

Expected behavior:
2 executions (1 initial + 1 retry)

Actual behavior:
3 executions (1 initial + 2 retries)

This PR corrects the calculation by converting attempts to retries:

maxRetries = maxAttempts - 1

A test (MaxAttemptsRetryTests) has been added to reproduce and verify
the correct behavior.

Fixes #3183

Thanks for reviewing this contribution.

…tion

The retry policy previously used maxRetries(properties.getMaxAttempts()), which caused an off-by-one error because maxRetries represents the number of retries while maxAttempts represents total delivery attempts.

Example:
maxAttempts=2 resulted in 3 executions (1 initial + 2 retries).

This change converts maxAttempts to retries by using:
maxRetries = maxAttempts - 1

A test (MaxAttemptsRetryTests) has been added to reproduce and verify the correct behavior.

Signed-off-by: vishwasio <im.vishwas.03@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consumer max attempts behavior changed - 2 attempts no longer possible

1 participant