简体   繁体   中英

Implement SkippableTasklet in Spring batch remote chunking with Chunk Oriented Processing

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM