Chaining multiple ItemProcessorListener

In this post under Spring Batch, I will explain with example how to chain multiple ItemProcessorListeners. For our example we create two ItemProcessorListener as shown below CustomItemProcessListener1 package package34; import org.springframework.batch.core.ItemProcessListener; public class CustomItemProcessListener1 implements ItemProcessListener { @Override public void afterProcess(Employee employee1, Employee employee2) { System.out.println(“CustomItemProcessListener1: Item processing completed”); } @Override public void beforeProcess(Employee employee)…… Continue reading Chaining multiple ItemProcessorListener

CompositeItemWriter Example

In this post under Spring Batch, I will explain with example the purpose of CompositeItemWriter and how to use it. In all the previous post’s examples under Spring Batch, I have used only one writer bean. The writer bean’s job was to write the items read to a file as shown below <bean id=”writer” class=”org.springframework.batch.item.file.FlatFileItemWriter”>…… Continue reading CompositeItemWriter Example

Excluding exceptions from skipping

In my previous posts under Spring Batch, I showed that when reading, processing or writing records in a batch, exceptions can be thrown, we can skip them and move on to next record. This is done with xml configuration as shown below 1 <batch:job id=”importEmployees”> 2 <batch:step id=”readWriteEmployees”> 3 <batch:tasklet> 4 <batch:chunk reader=”reader” writer=”writer” commit-interval=”50″…… Continue reading Excluding exceptions from skipping

ExceptionClassifierSkipPolicy example

In this post under Spring Batch, I will explain with an example how to use Spring Batch provided ExceptionClassifierSkipPolicy class. ExceptionClassifierSkipPolicy will not contain the logic of how to handle exceptions when thrown. Instead it is a delegator class which passes the exceptions thrown to appropriate exception handling SkipPolicy classes. ExceptionClassifierSkipPolicy will contain a map…… Continue reading ExceptionClassifierSkipPolicy example

Configuring Multiple SkipListeners

In this post under Spring Batch, I will show with example how to configure multiple Skip listeners. In my previous post, I showed how to configure a bean as skip listeners. For recap purpose below is the xml for your reference 1 <bean id=”mySkipListener” class=”package25.MySkipListener”/> 2 3 <batch:job id=”importEmployees”> 4 <batch:step id=”readWriteEmployees”> 5 <batch:tasklet> 6…… Continue reading Configuring Multiple SkipListeners

Changing Skip Policy to out of box provided skip policies

In this post under Spring Batch, I will explain how to change skip policy to one of out of the box provided skip policies. Whenever we use the “skip-limit” attribute and “skippable-exception-classes” element as shown below at line 4 and 5 1 <batch:job id=”importEmployees”> 2 <batch:step id=”readWriteEmployees”> 3 <batch:tasklet> 4 <batch:chunk reader=”reader” writer=”writer” commit-interval=”50″ skip-limit=”200″>…… Continue reading Changing Skip Policy to out of box provided skip policies

Listening to Skip events using SkipListener

In this post under Spring Batch, I will explain with an example of how to listen to skip events. The skip events are generated during reading, writing, and processing of records. We can listen to these skip events with the help of org.springframework.batch.core.SkipListener interface. The SkipListener interface has three methods 1) onSkipInProcess purpose –> provide…… Continue reading Listening to Skip events using SkipListener