Skip to content

Add ExponentialBackoffErrorHandler to manage message visibility tim…#1381

Merged
tomazfernandes merged 1 commit into
awspring:mainfrom
brun0-4ugusto:backoff-error-handler
May 18, 2025
Merged

Add ExponentialBackoffErrorHandler to manage message visibility tim…#1381
tomazfernandes merged 1 commit into
awspring:mainfrom
brun0-4ugusto:backoff-error-handler

Conversation

@brun0-4ugusto
Copy link
Copy Markdown
Contributor

@brun0-4ugusto brun0-4ugusto commented May 8, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

New ExponentialBackoffErrorHandler to change message visibility timeout exponentially based on the number of receive Message Count

💡 Motivation and Context

As mentioned in (#1313), this enhancement enables reporting an error back to AWS SQS by exponentially increasing the message's visibility timeout, allowing it to be retried.

See #1314

💚 How did you test it?

Unit test, Integration test, manual tests with a sample application

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

  • Update sample application

@github-actions github-actions Bot added the component: sqs SQS integration related issue label May 8, 2025
Copy link
Copy Markdown
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

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

Looking great @brun0-4ugusto and @rafaelcgpava!

I left a few of comments in the code, please let me know if they make sense.

We can add some debug or trace logs so we can follow whether visibility change was successful and to what value it was changed to for a given message id.

We also need to decide what happens if visibility change fails for a given message or set of messages - we should at least log the error clearly with context.

Abstractions

Regarding abstractions, I can see where we could benefit from code reuse, but since it's not too much logic perhaps some duplication is ok?

We can also have a ErrorHandlerVisibilityHelper class with some utility methods.

Please let me know your thoughts on all of this, thanks!

@brun0-4ugusto brun0-4ugusto force-pushed the backoff-error-handler branch 2 times, most recently from 1ca5ed8 to 91f6156 Compare May 13, 2025 02:20
@brun0-4ugusto
Copy link
Copy Markdown
Contributor Author

brun0-4ugusto commented May 13, 2025

Hello @tomazfernandes,

I hope you’re doing well. We have implemented the requested changes—they were excellent ideas! We also took the opportunity to incorporate the new ErrorHandlerVisibilityHelper into the ImmediateRetryAsyncErrorHandler class. Please let us know if you have any further suggestions for improvement.

Thank you again! 😸

Copy link
Copy Markdown
Contributor

@tomazfernandes tomazfernandes left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, it's looking good!

Left a couple of comments. Also, please add docs on the new error handler.

@rafaelcgpava rafaelcgpava force-pushed the backoff-error-handler branch from 8bb87d0 to b7d0fa1 Compare May 15, 2025 00:35
@github-actions github-actions Bot added the type: documentation Documentation or Samples related issue label May 15, 2025
@rafaelcgpava rafaelcgpava force-pushed the backoff-error-handler branch from b7d0fa1 to f753bee Compare May 15, 2025 00:54
@brun0-4ugusto brun0-4ugusto force-pushed the backoff-error-handler branch from f753bee to f4d5bfc Compare May 15, 2025 01:56
…eouts and implement exponential backoff logic for retries in SQS (awspring#1314)

Co-authored-by: skilo <[email protected]>
@brun0-4ugusto
Copy link
Copy Markdown
Contributor Author

Hi @tomazfernandes ,

Thank you for your feedback and comments. We have addressed the points you raised and added documentation for the new error handler. Please let us know if you have any further suggestions or questions.

@tomazfernandes tomazfernandes merged commit 5d1ee37 into awspring:main May 18, 2025
5 checks passed
@tomazfernandes
Copy link
Copy Markdown
Contributor

Thanks for the PR @brun0-4ugusto and @rafaelcgpava!

I have two more issues in mind regarding error handling:

  • Create a LinearBackOffErrorHandler
  • Create a BackOffErrorHandlerFactory, where we can set the parameters we want and it'll return the proper implementation.

What do you think? Would you like to contribute those as well?

Let me know your thoughts, thanks!

@brun0-4ugusto
Copy link
Copy Markdown
Contributor Author

Hi @tomazfernandes Thanks for the review!
We’d be happy to contribute those as well! 😺

kcsurapaneni pushed a commit to kcsurapaneni/spring-cloud-aws that referenced this pull request Jun 13, 2025
@brun0-4ugusto
Copy link
Copy Markdown
Contributor Author

Hi @tomazfernandes, how are you?
Apologies for the delay. I’ve submitted a PR that provides a LinearBackOffErrorHandler and additional exponential jitter strategies. I’ll send another PR with the factory shortly. (#1422 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: sqs SQS integration related issue type: documentation Documentation or Samples related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants