Chaining multiple ChunkListeners

In this post under Spring Batch, I will explain how to chain multiple ChunkListener together. For this example I will create two custom ChunkListener interface implementations named ‘CustomChunkListener1’ and ‘CustomChunkListener2’ as shown below CustomChunkListener1 package package35; import org.springframework.batch.core.ChunkListener; import org.springframework.batch.core.scope.context.ChunkContext; public class CustomChunkListener1 implements ChunkListener { @Override public void afterChunk(ChunkContext chunkContext) { System.out.println(“ChunkListener1 processing ended…… Continue reading Chaining multiple ChunkListeners

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<Employee, Employee> { @Override public void afterProcess(Employee employee1, Employee employee2) { System.out.println(“CustomItemProcessListener1: Item processing completed”); } @Override public void beforeProcess(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

Implementing Custom Skip Policy

In my previous posts under Spring Batch, I explained with example how to use built in out of the box skip policies. In this post I will explain how to create our own custom skip policy and use it. To create our own custom skip policy we need to implement the interface org.springframework.batch.core.step.skip.SkipPolicy as shown…… Continue reading Implementing Custom Skip Policy

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