Skip to content

Add maxAttempts to ExponentialBackOff #27071

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

Closed
wants to merge 2 commits into from

Conversation

garyrussell
Copy link
Contributor

If you wish to stop after a certain number of attempts with an
ExponentialBackOff you have to calculate the maxElapsedTime
corresponding to the number of attempts.

See https://github.com/spring-projects/spring-kafka/blob/0ee2d49ea525de038d315bc243b62f1004a26dc6/spring-kafka/src/main/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetries.java#L74-L84

Add a new property to make it more convenient to stop after a
certain number of attempts.

If you wish to stop after a certain number of attempts with an
`ExponentialBackOff` you have to calculate the `maxElapsedTime`
corresponding to the number of attempts.

See https://github.com/spring-projects/spring-kafka/blob/0ee2d49ea525de038d315bc243b62f1004a26dc6/spring-kafka/src/main/java/org/springframework/kafka/support/ExponentialBackOffWithMaxRetries.java#L74-L84

Add a new property to make it more convenient to stop after a
certain number of attempts.
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple Checkstyle issues:

[ant:checkstyle] [ERROR] /tmp/build/f663b219/git-repo/spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java:79:9: Missing a Javadoc comment. [JavadocVariable]

[ant:checkstyle] [ERROR] /tmp/build/f663b219/git-repo/spring-core/src/main/java/org/springframework/util/backoff/ExponentialBackOff.java:195:24: Reference to instance variable 'maxAttempts' needs "this.". [RequireThis]

See Concourse CI report for PR.

* The maximum number of attempts after which a call to
* {@link BackOffExecution#nextBackOff()} returns {@link BackOffExecution#STOP}.
* @param maxAttempts the maxAttempts.
* @see #setMaxElapsedTime(long)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably some @since has to be here on public API.
Let's start from the current one and we'll see how this PR going to be approved!

@rstoyanchev rstoyanchev added the in: core Issues in core modules (aop, beans, core, context, expression) label Nov 11, 2021
@snicoll snicoll self-assigned this Aug 26, 2023
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 26, 2023
@snicoll snicoll added this to the 6.1.0-RC1 milestone Aug 26, 2023
snicoll pushed a commit that referenced this pull request Aug 26, 2023
If you wish to stop after a certain number of attempts with an
`ExponentialBackOff` you have to calculate the `maxElapsedTime`
corresponding to the number of attempts.

Add a new property to make it more convenient to stop after a
certain number of attempts.

See gh-27071
snicoll added a commit that referenced this pull request Aug 26, 2023
@snicoll snicoll closed this in 962f4d2 Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants