Skip to content
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

Allow use of custom (binary) exception classifier in RestTemplateBuilder #441

Closed
morulay opened this issue Jun 1, 2024 · 0 comments
Closed
Milestone

Comments

@morulay
Copy link
Contributor

morulay commented Jun 1, 2024

Some DBs hint with specific vendor code or SQLState if a DB request/transaction could be retried in case of exception, e.g. exception instanceof SQLException sqlException && "12345".equals(sqlException.getErrorCode()) . spring-retry can handle this case either with:

  • Utility class holding the predicate (classifier) + SPeL and ExpressionRetryPolicy - not very fast due to the expression evaluation
  • Assembling manually RestTemplate with custom RetryPolicy - more error prone and lacks the convenience of RetryTemplate.builder()

Both solutions have drawbacks and mostly lacks the convenience of RetryTemplate.builder().

Do you think it is possible to allow the use of custom (binary) exception classifier in RetryTemplate.builder(). Here is an example to depict the idea:

RetryTemplate retryTemplate = RetryTemplate.builder()
  .maxAtmepts(3)
  .customExceptionClassifier(classifiable -> classifiable instanceof SQLException sqlException
      && "retry_vendor_code".equals(sqlException.getErrorCode()))
  .build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants