0
votes

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

1 Answers

1
votes

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