Implement SkippableTasklet in Spring batch remote chunking with Chunk Oriented Processing

杀马特。学长 韩版系。学妹 提交于 2019-12-13 20:14:33

问题


I'm currently using Spring Batch and want to use remote chunking.

I use chunk oriented processing that use Item Reader, Item Processor and Item Writer and want to implement skip.

I read in this question that told me to create SkippableTasklet but I kinda confuse how to implement protected abstract void run(JobParameters jobParameters) throws Exception;

How can I implement skip in this remote chunking implementation?


回答1:


There are couple of ways to handle skippable exception. I have written this way

<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
   };
}


来源:https://stackoverflow.com/questions/47788407/implement-skippabletasklet-in-spring-batch-remote-chunking-with-chunk-oriented-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!