spring - 带有 RetryableException 处理(而不是 NotRetryableException)的 SeekToCurrentErrorHandler
问题描述
实际SeekToCurrentErrorHandler
可以添加不可重试的异常,即除了最初的异常外,所有的异常都是可重试的,并添加了 X、Y、Z 异常。
愚蠢的问题:有没有一种简单的方法可以做相反的事情:所有异常都不可重试,除了 X',Y',Z'...
解决方案
是的,可以看到该类的这个配置方法:
/**
* Set an exception classifications to determine whether the exception should cause a retry
* (until exhaustion) or not. If not, we go straight to the recoverer. By default,
* the following exceptions will not be retried:
* <ul>
* <li>{@link DeserializationException}</li>
* <li>{@link MessageConversionException}</li>
* <li>{@link MethodArgumentResolutionException}</li>
* <li>{@link NoSuchMethodException}</li>
* <li>{@link ClassCastException}</li>
* </ul>
* All others will be retried.
* When calling this method, the defaults will not be applied.
* @param classifications the classifications.
* @param defaultValue whether or not to retry non-matching exceptions.
* @see BinaryExceptionClassifier#BinaryExceptionClassifier(Map, boolean)
* @see #addNotRetryableExceptions(Class...)
*/
public void setClassifications(Map<Class<? extends Throwable>, Boolean> classifications, boolean defaultValue) {
因此,要使所有内容都不可重试,您需要提供一个默认值作为false
. 然后,该地图应包含您希望可重试的那些异常,键的值为true
.
推荐阅读
- node.js - 每当我将 Node 应用程序部署到应用程序引擎时,应用程序引擎都会创建新版本
- sql - Sql server,从未来日期获取结果,除非是周末
- reactjs - 如何在 React 应用程序中使用路由来打开已经存在的 flex 应用程序的特定页面?
- html - ngx-translate 在角度 8 中的 terinory 条件
- android - 在 Amazon Kinesis Video Streams 中获取语音和视频流的解决方案
- spring-boot - Lombok 和 Spring Boot 问题 - 无法在类上找到适当的构造函数
- sql-server - 恢复卡在处理中的 TRN 文件
- java - '没有主要清单属性' Gradle 没有创建清单文件夹和文件?
- javascript - 我需要添加支付集成我需要知道什么?
- html - Bookdown - 数学中的定理参考?