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()
Some DBs hint with specific vendor code or
SQLStateif a DB request/transaction could be retried in case of exception, e.g.exception instanceof SQLException sqlException && "12345".equals(sqlException.getErrorCode()).spring-retrycan handle this case either with:ExpressionRetryPolicy- not very fast due to the expression evaluationRestTemplatewith customRetryPolicy- more error prone and lacks the convenience ofRetryTemplate.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: