Skip to content

Introduce minimal retry functionality as a core framework feature #34716

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 1 commit into from

Conversation

fmbenhassine
Copy link
Contributor

@fmbenhassine fmbenhassine commented Apr 4, 2025

This PR introduces a minimal core retry feature in Spring Framework. It is inspired by Spring Retry, but redesigned and trimmed to the bare minimum to cover most cases.

The main entry point is the RetryTemplate class, which is designed in a similar fashion to other templates provided by Spring. The package is minimal on purpose to keep its usage as simple as possible (see examples in RetryTemplateTests). It focuses only on stateless retries for now, but can be extended with other retry operations as well.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 4, 2025
@sbrannen sbrannen changed the title Introduce a minimal retry functionality as a core framework feature Introduce minimal retry functionality as a core framework feature Apr 4, 2025
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Apr 4, 2025
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

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

Hi @fmbenhassine,

First and foremost, thanks for putting this PR together! 👍

I took a quick look, added a few comments, and asked a few questions (as food for thought).

And we will also discuss the proposal within the team.

Cheers,

Sam

@fmbenhassine
Copy link
Contributor Author

Thank you for the review, @sbrannen !

I added a couple of inline comments and I will update the PR accordingly.

@fmbenhassine
Copy link
Contributor Author

I updated the PR with the following changes:

  • Add/Use a specific RetryException in the API instead of the generic Exception
  • Add RetryCallback interface with a logical name for diagnostics purposes
  • Improve RetryPolicy with the ability to specify which exceptions to retry based on a Predicate<Exception>

I find this new version to be more coherent and consistent with other templates in terms of structure and API. Looking forward to the team's thoughts on this!

@fmbenhassine fmbenhassine force-pushed the spring-retry branch 2 times, most recently from 5facde5 to b7a7ca6 Compare May 27, 2025 13:22
@fmbenhassine fmbenhassine requested a review from sbrannen May 27, 2025 13:25
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.

This is great even if I have left so many questions.
Thanks

@fmbenhassine
Copy link
Contributor Author

Thank you for the review, @artembilan and @sbrannen !

I updated the PR accordingly and added a few comments. Please let me know if we need other updates.

The build of the PR is failing for tests that are not related to this change set.

@spencergibb
Copy link
Member

👋🏻 Joining the conversation here as Spring Cloud is an advanced user of Spring Retry, so we would be interested in how the functionality compares to the Spring Retry project.

@spencergibb

This comment was marked as outdated.

@sbrannen

This comment was marked as outdated.

@jhoeller jhoeller added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 4, 2025
@jhoeller jhoeller added this to the 7.0.0-M6 milestone Jun 4, 2025
This commit introduces a minimal core retry feature. It is inspired
by Spring Retry, but redesigned and trimmed to the bare minimum to
cover most cases.
@sbrannen sbrannen closed this in 3fb4a75 Jun 5, 2025
sbrannen added a commit that referenced this pull request Jun 5, 2025
This commit constitutes a first pass over the new core retry support.

- Fix code and Javadoc formatting

- Polish/fix Javadoc

- Fix default FixedBackOff configuration in RetryTemplate

- Consistent logging in RetryTemplate

- Fix listener handling in CompositeRetryListener, allowing addListener()
  to work

- Polish tests

- Ensure RetryTemplateTests do not take over 30 seconds to execute

See gh-34716
@sbrannen
Copy link
Member

sbrannen commented Jun 5, 2025

This has been merged into main in 3fb4a75 and slightly revised in 02af9e5. 🚀

Thanks everybody for the collaborative effort to get this into 7.0!

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.

6 participants