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 <batch:chunk reader="reader" writer="writer" commit-interval="50" skip-limit="200">
7 <batch:skippable-exception-classes>
8 <batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
9 </batch:skippable-exception-classes>
10 </batch:chunk>
11 <batch:listeners>
12 <batch:listener ref="mySkipListener"/>
13 </batch:listeners>
14 </batch:tasklet>
15 </batch:step>
16 </batch:job>
In the above xml code, at line 1 we have defined a bean for class “MySkipListener” named “mySkipListener”.
We refer that bean at line 12 using “listener” batch xml element.
In this way we register a skip listener.
Now I will show how to register multiple skip listeners.
For our example we create two skip listener classes “MySkipListener1” and “MySkipListener2”. The code is as shown below
MySkipListener1
package package28;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.item.file.FlatFileParseException;
public class MySkipListener1 implements SkipListener<Employee, Employee> {
@Override
public void onSkipInProcess(Employee employee, Throwable throwable) {
}
@Override
public void onSkipInRead(Throwable throwable) {
if(throwable instanceof FlatFileParseException) {
FlatFileParseException flatFileParseException = (FlatFileParseException) throwable;
String message = flatFileParseException.getMessage() + "-" + flatFileParseException.getLineNumber();
System.out.println("MySkipListener1" + message);
}
}
@Override
public void onSkipInWrite(Employee employee, Throwable throwable) {
}
}
MySkipListener1
package package28;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.item.file.FlatFileParseException;
public class MySkipListener2 implements SkipListener<Employee, Employee> {
@Override
public void onSkipInProcess(Employee employee, Throwable throwable) {
}
@Override
public void onSkipInRead(Throwable throwable) {
if(throwable instanceof FlatFileParseException) {
FlatFileParseException flatFileParseException = (FlatFileParseException) throwable;
String message = flatFileParseException.getMessage() + "-" + flatFileParseException.getLineNumber();
System.out.println("MySkipListener2" + message);
}
}
@Override
public void onSkipInWrite(Employee employee, Throwable throwable) {
}
}
Now below is the xml code to register both the classes as skip listeners
1 <bean id="mySkipListener1" class="package28.MySkipListener1"/>
2 <bean id="mySkipListener2" class="package28.MySkipListener2"/>
3
4 <batch:job id="importEmployees">
5 <batch:step id="readWriteEmployees">
6 <batch:tasklet>
7 <batch:chunk reader="reader" writer="writer" commit-interval="50" skip-limit="200">
8 <batch:skippable-exception-classes>
9 <batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
10 </batch:skippable-exception-classes>
11 </batch:chunk>
12 <batch:listeners>
13 <batch:listener ref="mySkipListener2"/>
14 <batch:listener ref="mySkipListener1"/>
15 </batch:listeners>
16 </batch:tasklet>
17 </batch:step>
18 </batch:job>
In the above xml code at line 1 and line 2, we have created two beans definitions, one for “MySkipListener1” class named “mySkipListener1” and another for
“MySkipListener2” class named “mySkipListener2”.
Next at line 13 and 14, I have registered those listeners using “listener” batch xml element.
The listeners will be called in the order they are listed in the xml code.
So in this example, mySkipListener2 class’s method will be called and then mySkipListener1 class’s method.
Below is the output
Output
Mar 14, 2020 11:58:12 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5b80350b: startup date [Sat Mar 14 11:58:12 IST 2020]; root of context hierarchy
Mar 14, 2020 11:58:12 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [package28/job.xml]
Mar 14, 2020 11:58:13 AM org.springframework.batch.core.launch.support.SimpleJobLauncher afterPropertiesSet
INFO: No TaskExecutor has been set, defaulting to synchronous executor.
Mar 14, 2020 11:58:13 AM org.springframework.batch.core.launch.support.SimpleJobLauncher run
INFO: Job: [FlowJob: [name=importEmployees]] launched with the following parameters: [{date=1584167293630}]
Mar 14, 2020 11:58:13 AM org.springframework.batch.core.job.SimpleStepHandler handleStep
INFO: Executing step: [readWriteEmployees]
MySkipListener2Parsing error at line: 2 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID1,EMP_NAME1,EMP_STATUS1,Hello]-2
MySkipListener1Parsing error at line: 2 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID1,EMP_NAME1,EMP_STATUS1,Hello]-2
MySkipListener2Parsing error at line: 4 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID3,EMP_NAME3,EMP_STATUS3,Hello]-4
MySkipListener1Parsing error at line: 4 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID3,EMP_NAME3,EMP_STATUS3,Hello]-4
MySkipListener2Parsing error at line: 6 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID5,EMP_NAME5,EMP_STATUS5,Hello]-6
MySkipListener1Parsing error at line: 6 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID5,EMP_NAME5,EMP_STATUS5,Hello]-6
MySkipListener2Parsing error at line: 8 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID7,EMP_NAME7,EMP_STATUS7,Hello]-8
MySkipListener1Parsing error at line: 8 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID7,EMP_NAME7,EMP_STATUS7,Hello]-8
MySkipListener2Parsing error at line: 10 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID9,EMP_NAME9,EMP_STATUS9,Hello]-10
MySkipListener1Parsing error at line: 10 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID9,EMP_NAME9,EMP_STATUS9,Hello]-10
MySkipListener2Parsing error at line: 12 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID11,EMP_NAME11,EMP_STATUS11,Hello]-12
MySkipListener1Parsing error at line: 12 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID11,EMP_NAME11,EMP_STATUS11,Hello]-12
MySkipListener2Parsing error at line: 14 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID13,EMP_NAME13,EMP_STATUS13,Hello]-14
MySkipListener1Parsing error at line: 14 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID13,EMP_NAME13,EMP_STATUS13,Hello]-14
MySkipListener2Parsing error at line: 16 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID15,EMP_NAME15,EMP_STATUS15,Hello]-16
MySkipListener1Parsing error at line: 16 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID15,EMP_NAME15,EMP_STATUS15,Hello]-16
MySkipListener2Parsing error at line: 18 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID17,EMP_NAME17,EMP_STATUS17,Hello]-18
MySkipListener1Parsing error at line: 18 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID17,EMP_NAME17,EMP_STATUS17,Hello]-18
MySkipListener2Parsing error at line: 20 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID19,EMP_NAME19,EMP_STATUS19,Hello]-20
MySkipListener1Parsing error at line: 20 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID19,EMP_NAME19,EMP_STATUS19,Hello]-20
MySkipListener2Parsing error at line: 22 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID21,EMP_NAME21,EMP_STATUS21,Hello]-22
MySkipListener1Parsing error at line: 22 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID21,EMP_NAME21,EMP_STATUS21,Hello]-22
MySkipListener2Parsing error at line: 24 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID23,EMP_NAME23,EMP_STATUS23,Hello]-24
MySkipListener1Parsing error at line: 24 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID23,EMP_NAME23,EMP_STATUS23,Hello]-24
MySkipListener2Parsing error at line: 26 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID25,EMP_NAME25,EMP_STATUS25,Hello]-26
MySkipListener1Parsing error at line: 26 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID25,EMP_NAME25,EMP_STATUS25,Hello]-26
MySkipListener2Parsing error at line: 28 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID27,EMP_NAME27,EMP_STATUS27,Hello]-28
MySkipListener1Parsing error at line: 28 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID27,EMP_NAME27,EMP_STATUS27,Hello]-28
MySkipListener2Parsing error at line: 30 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID29,EMP_NAME29,EMP_STATUS29,Hello]-30
MySkipListener1Parsing error at line: 30 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID29,EMP_NAME29,EMP_STATUS29,Hello]-30
MySkipListener2Parsing error at line: 32 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID31,EMP_NAME31,EMP_STATUS31,Hello]-32
MySkipListener1Parsing error at line: 32 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID31,EMP_NAME31,EMP_STATUS31,Hello]-32
MySkipListener2Parsing error at line: 34 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID33,EMP_NAME33,EMP_STATUS33,Hello]-34
MySkipListener1Parsing error at line: 34 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID33,EMP_NAME33,EMP_STATUS33,Hello]-34
MySkipListener2Parsing error at line: 36 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID35,EMP_NAME35,EMP_STATUS35,Hello]-36
MySkipListener1Parsing error at line: 36 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID35,EMP_NAME35,EMP_STATUS35,Hello]-36
MySkipListener2Parsing error at line: 38 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID37,EMP_NAME37,EMP_STATUS37,Hello]-38
MySkipListener1Parsing error at line: 38 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID37,EMP_NAME37,EMP_STATUS37,Hello]-38
MySkipListener2Parsing error at line: 40 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID39,EMP_NAME39,EMP_STATUS39,Hello]-40
MySkipListener1Parsing error at line: 40 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID39,EMP_NAME39,EMP_STATUS39,Hello]-40
MySkipListener2Parsing error at line: 42 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID41,EMP_NAME41,EMP_STATUS41,Hello]-42
MySkipListener1Parsing error at line: 42 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID41,EMP_NAME41,EMP_STATUS41,Hello]-42
MySkipListener2Parsing error at line: 44 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID43,EMP_NAME43,EMP_STATUS43,Hello]-44
MySkipListener1Parsing error at line: 44 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID43,EMP_NAME43,EMP_STATUS43,Hello]-44
MySkipListener2Parsing error at line: 46 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID45,EMP_NAME45,EMP_STATUS45,Hello]-46
MySkipListener1Parsing error at line: 46 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID45,EMP_NAME45,EMP_STATUS45,Hello]-46
MySkipListener2Parsing error at line: 48 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID47,EMP_NAME47,EMP_STATUS47,Hello]-48
MySkipListener1Parsing error at line: 48 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID47,EMP_NAME47,EMP_STATUS47,Hello]-48
MySkipListener2Parsing error at line: 50 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID49,EMP_NAME49,EMP_STATUS49,Hello]-50
MySkipListener1Parsing error at line: 50 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID49,EMP_NAME49,EMP_STATUS49,Hello]-50
MySkipListener2Parsing error at line: 52 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID51,EMP_NAME51,EMP_STATUS51,Hello]-52
MySkipListener1Parsing error at line: 52 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID51,EMP_NAME51,EMP_STATUS51,Hello]-52
MySkipListener2Parsing error at line: 54 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID53,EMP_NAME53,EMP_STATUS53,Hello]-54
MySkipListener1Parsing error at line: 54 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID53,EMP_NAME53,EMP_STATUS53,Hello]-54
MySkipListener2Parsing error at line: 56 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID55,EMP_NAME55,EMP_STATUS55,Hello]-56
MySkipListener1Parsing error at line: 56 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID55,EMP_NAME55,EMP_STATUS55,Hello]-56
MySkipListener2Parsing error at line: 58 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID57,EMP_NAME57,EMP_STATUS57,Hello]-58
MySkipListener1Parsing error at line: 58 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID57,EMP_NAME57,EMP_STATUS57,Hello]-58
MySkipListener2Parsing error at line: 60 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID59,EMP_NAME59,EMP_STATUS59,Hello]-60
MySkipListener1Parsing error at line: 60 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID59,EMP_NAME59,EMP_STATUS59,Hello]-60
MySkipListener2Parsing error at line: 62 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID61,EMP_NAME61,EMP_STATUS61,Hello]-62
MySkipListener1Parsing error at line: 62 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID61,EMP_NAME61,EMP_STATUS61,Hello]-62
MySkipListener2Parsing error at line: 64 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID63,EMP_NAME63,EMP_STATUS63,Hello]-64
MySkipListener1Parsing error at line: 64 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID63,EMP_NAME63,EMP_STATUS63,Hello]-64
MySkipListener2Parsing error at line: 66 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID65,EMP_NAME65,EMP_STATUS65,Hello]-66
MySkipListener1Parsing error at line: 66 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID65,EMP_NAME65,EMP_STATUS65,Hello]-66
MySkipListener2Parsing error at line: 68 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID67,EMP_NAME67,EMP_STATUS67,Hello]-68
MySkipListener1Parsing error at line: 68 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID67,EMP_NAME67,EMP_STATUS67,Hello]-68
MySkipListener2Parsing error at line: 70 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID69,EMP_NAME69,EMP_STATUS69,Hello]-70
MySkipListener1Parsing error at line: 70 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID69,EMP_NAME69,EMP_STATUS69,Hello]-70
MySkipListener2Parsing error at line: 72 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID71,EMP_NAME71,EMP_STATUS71,Hello]-72
MySkipListener1Parsing error at line: 72 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID71,EMP_NAME71,EMP_STATUS71,Hello]-72
MySkipListener2Parsing error at line: 74 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID73,EMP_NAME73,EMP_STATUS73,Hello]-74
MySkipListener1Parsing error at line: 74 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID73,EMP_NAME73,EMP_STATUS73,Hello]-74
MySkipListener2Parsing error at line: 76 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID75,EMP_NAME75,EMP_STATUS75,Hello]-76
MySkipListener1Parsing error at line: 76 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID75,EMP_NAME75,EMP_STATUS75,Hello]-76
MySkipListener2Parsing error at line: 78 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID77,EMP_NAME77,EMP_STATUS77,Hello]-78
MySkipListener1Parsing error at line: 78 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID77,EMP_NAME77,EMP_STATUS77,Hello]-78
MySkipListener2Parsing error at line: 80 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID79,EMP_NAME79,EMP_STATUS79,Hello]-80
MySkipListener1Parsing error at line: 80 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID79,EMP_NAME79,EMP_STATUS79,Hello]-80
MySkipListener2Parsing error at line: 82 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID81,EMP_NAME81,EMP_STATUS81,Hello]-82
MySkipListener1Parsing error at line: 82 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID81,EMP_NAME81,EMP_STATUS81,Hello]-82
MySkipListener2Parsing error at line: 84 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID83,EMP_NAME83,EMP_STATUS83,Hello]-84
MySkipListener1Parsing error at line: 84 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID83,EMP_NAME83,EMP_STATUS83,Hello]-84
MySkipListener2Parsing error at line: 86 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID85,EMP_NAME85,EMP_STATUS85,Hello]-86
MySkipListener1Parsing error at line: 86 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID85,EMP_NAME85,EMP_STATUS85,Hello]-86
MySkipListener2Parsing error at line: 88 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID87,EMP_NAME87,EMP_STATUS87,Hello]-88
MySkipListener1Parsing error at line: 88 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID87,EMP_NAME87,EMP_STATUS87,Hello]-88
MySkipListener2Parsing error at line: 90 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID89,EMP_NAME89,EMP_STATUS89,Hello]-90
MySkipListener1Parsing error at line: 90 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID89,EMP_NAME89,EMP_STATUS89,Hello]-90
MySkipListener2Parsing error at line: 92 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID91,EMP_NAME91,EMP_STATUS91,Hello]-92
MySkipListener1Parsing error at line: 92 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID91,EMP_NAME91,EMP_STATUS91,Hello]-92
MySkipListener2Parsing error at line: 94 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID93,EMP_NAME93,EMP_STATUS93,Hello]-94
MySkipListener1Parsing error at line: 94 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID93,EMP_NAME93,EMP_STATUS93,Hello]-94
MySkipListener2Parsing error at line: 96 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID95,EMP_NAME95,EMP_STATUS95,Hello]-96
MySkipListener1Parsing error at line: 96 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID95,EMP_NAME95,EMP_STATUS95,Hello]-96
MySkipListener2Parsing error at line: 98 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID97,EMP_NAME97,EMP_STATUS97,Hello]-98
MySkipListener1Parsing error at line: 98 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID97,EMP_NAME97,EMP_STATUS97,Hello]-98
MySkipListener2Parsing error at line: 100 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID99,EMP_NAME99,EMP_STATUS99,Hello]-100
MySkipListener1Parsing error at line: 100 in resource=[URL [file:FileInput8.txt]], input=[EMP_ID99,EMP_NAME99,EMP_STATUS99,Hello]-100
Mar 14, 2020 11:58:13 AM org.springframework.batch.core.launch.support.SimpleJobLauncher run
INFO: Job: [FlowJob: [name=importEmployees]] completed with the following parameters: [{date=1584167293630}] and the following status: [COMPLETED]
Below is the complete xml code for your reference.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd">
<bean id="employee" class="package28.Employee" scope="prototype"/>
<bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="file:FileInput8.txt"/>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="id,name,status,salary"/>
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="employee"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" value="file:FileOutput.txt"/>
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="fieldExtractor">
<bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names" value="id,name,status,salary"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="mySkipListener1" class="package28.MySkipListener1"/>
<bean id="mySkipListener2" class="package28.MySkipListener2"/>
<batch:job id="importEmployees">
<batch:step id="readWriteEmployees">
<batch:tasklet>
<batch:chunk reader="reader" writer="writer" commit-interval="50" skip-limit="200">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.file.FlatFileParseException"/>
</batch:skippable-exception-classes>
</batch:chunk>
<batch:listeners>
<batch:listener ref="mySkipListener2"/>
<batch:listener ref="mySkipListener1"/>
</batch:listeners>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
</bean>
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository"/>
</bean>
</beans>