gpt4 book ai didi

java - 使用面向 block 的处理在 Spring 批量远程分块中实现 SkippableTasklet

转载 作者:行者123 更新时间:2023-12-02 11:52:30 25 4
gpt4 key购买 nike

我目前正在使用 Spring Batch,并且想要使用远程分块。

我使用面向 block 的处理,使用项目读取器、项目处理器和项目写入器,并希望实现跳过。

我读过这个question这告诉我创建 SkippableTasklet 但我有点困惑如何实现 protected abstract void run(JobParameters jobParameters) throws Exception;

如何在此远程分块实现中实现跳过?

最佳答案

有几种方法可以处理可跳过的异常。我是这样写的

<batch:step id="sendEmailStep">
<batch:tasklet>
<bean class="com.myproject.SendEmail" scope="step" autowire="byType">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.mail.MailException" />
</batch:skippable-exception-classes>
</bean>
</batch:tasklet>
<batch:listeners>
batch:listener ref="skippableListener'/>
</batch:listeners>
</batch:step>
<bean id="skippableListener" class="SkippableListener/>

public class SkippableListener implements SkipListener
{
void onSkipInProcess(T item, java.lang.Throwable t){
//Write your logic
};
void onSkipInRead(java.lang.Throwable t){
//Write your logic
};
void onSkipInWrite(S item, java.lang.Throwable t){
//Write your logic
};
}

关于java - 使用面向 block 的处理在 Spring 批量远程分块中实现 SkippableTasklet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47788407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com