Spring 批处理 Jsr 352,跳过管理处理器 outside/before 跳过侦听器

Spring Batch Jsr 352, manage processor skip outside/before skip listener

我正在尝试找到一种方法来管理进程侦听器中的跳过场景(或者也可以是读或写侦听器)。我发现跳过监听器似乎是在进程监听器的 on error 方法之后执行的。这意味着我可能会以某种方式处理错误,而不知道它是一个要跳过的异常。

有什么方法可以知道跳过侦听器之外的特定异常被跳过了吗?可以被拉入进程侦听器或其他地方的东西。

我发现执行此操作的最佳方法是将 属性 添加到步骤,然后在我需要的步骤上下文中进行连接。

<step id="firstStep">
   <properties> <property name="skippableExceptions" value="java.lang.IllegalArgumentException"/> </properties>
</step>

这不是一个完美的解决方案,但是跳过异常似乎只在 StepFactoryBean 和 Tasklet 中设置并且不能直接访问。

我的听众中的代码

@Inject
StepContext stepContext;
.
.
.
Properties p = stepContext.getProperties();
String exceptions = p.getProperty("skippableExceptions");