BATCHADM-63: add integration test for JDBC remote chunking
This commit is contained in:
committed by
Michael Minella
parent
b4092611d7
commit
b5611e051d
@@ -1,12 +1,13 @@
|
||||
#Fri Aug 20 12:09:08 BST 2010
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/ChunkStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1102" endstart\="1096" start\="901" startend\="967"/>\n<bounds height\="118" width\="79" x\="15" y\="17"/>\n</element>\n<element type\="job">\n<structure end\="1473" endstart\="1467" start\="1107" startend\="1182"/>\n<bounds height\="118" width\="127" x\="106" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="1667" endstart\="1661" start\="1306" startend\="1372"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="1767" endstart\="1761" start\="1416" startend\="1482"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1267" endstart\="1261" start\="1065" startend\="1131"/>\n<bounds height\="118" width\="79" x\="15" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/file/FileToMessagesJobIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="972" endstart\="966" start\="771" startend\="837"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/partition/VanillaIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="2963" endstart\="2957" start\="2768" startend\="2835"/>\n<bounds height\="128" width\="131" x\="100" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="3569" endstart\="3562" start\="3069" startend\="3138"/>\n<bounds height\="34" width\="65" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/step/StepGatewayIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1419" endstart\="1413" start\="1302" startend\="1368"/>\n<bounds height\="128" width\="79" x\="109" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="1953" endstart\="1946" start\="1846" startend\="1916"/>\n<bounds height\="34" width\="74" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/tasklet/StepGatewayIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1421" endstart\="1415" start\="1302" startend\="1368"/>\n<bounds height\="128" width\="79" x\="109" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="1962" endstart\="1955" start\="1855" startend\="1925"/>\n<bounds height\="34" width\="74" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="channel">\r\n<structure end\="2988" endstart\="2988" start\="2951" startend\="2988"/>\r\n<bounds height\="99" width\="118" x\="19" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="3188" endstart\="3166" start\="3089" startend\="3138"/>\r\n<bounds height\="99" width\="118" x\="295" y\="17"/>\r\n</element>\r\n<element type\="service-activator">\r\n<structure end\="3293" endstart\="3293" start\="3191" startend\="3293"/>\r\n<bounds height\="100" width\="118" x\="157" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="outbound-channel-adapter">\r\n<structure end\="2871" endstart\="2871" start\="2747" startend\="2871"/>\r\n<bounds height\="100" width\="155" x\="157" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="2910" endstart\="2910" start\="2873" startend\="2910"/>\r\n<bounds height\="99" width\="118" x\="19" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="2949" endstart\="2949" start\="2912" startend\="2949"/>\r\n<bounds height\="99" width\="118" x\="19" y\="137"/>\r\n</element>\r\n<element type\="transformer">\r\n<structure end\="3070" endstart\="3070" start\="2952" startend\="3070"/>\r\n<bounds height\="100" width\="155" x\="157" y\="137"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="4339" endstart\="4317" start\="3541" startend\="3590"/>\r\n<bounds height\="99" width\="118" x\="332" y\="137"/>\r\n</element>\r\n<element type\="interceptors">\r\n<structure end\="4315" endstart\="4288" start\="3617" startend\="3643"/>\r\n<bounds height\="53" width\="1" x\="468" y\="129"/>\r\n</element>\r\n</graph>
|
||||
eclipse.preferences.version=1
|
||||
#Sun Aug 22 19:15:30 BST 2010
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/ChunkStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1102" endstart\="1096" start\="901" startend\="967"/>\n<bounds height\="118" width\="79" x\="15" y\="17"/>\n</element>\n<element type\="job">\n<structure end\="1473" endstart\="1467" start\="1107" startend\="1182"/>\n<bounds height\="118" width\="127" x\="106" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="1667" endstart\="1661" start\="1306" startend\="1372"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJdbcIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1937" endstart\="1931" start\="1576" startend\="1642"/>\n<bounds height\="118" width\="82" x\="15" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="1767" endstart\="1761" start\="1416" startend\="1482"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1267" endstart\="1261" start\="1065" startend\="1131"/>\n<bounds height\="118" width\="79" x\="15" y\="17"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/file/FileToMessagesJobIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="job">\r\n<structure end\="972" endstart\="966" start\="771" startend\="837"/>\r\n<bounds height\="118" width\="75" x\="15" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/partition/VanillaIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="2963" endstart\="2957" start\="2768" startend\="2835"/>\n<bounds height\="128" width\="131" x\="100" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="3569" endstart\="3562" start\="3069" startend\="3138"/>\n<bounds height\="34" width\="65" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/step/StepGatewayIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1419" endstart\="1413" start\="1302" startend\="1368"/>\n<bounds height\="128" width\="79" x\="109" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="1953" endstart\="1946" start\="1846" startend\="1916"/>\n<bounds height\="34" width\="74" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/batch\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/tasklet/StepGatewayIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element type\="job">\n<structure end\="1421" endstart\="1415" start\="1302" startend\="1368"/>\n<bounds height\="128" width\="79" x\="109" y\="19"/>\n</element>\n<element type\="step">\n<structure end\="1962" endstart\="1955" start\="1855" startend\="1925"/>\n<bounds height\="34" width\="74" x\="17" y\="19"/>\n</element>\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="channel">\r\n<structure end\="2988" endstart\="2988" start\="2951" startend\="2988"/>\r\n<bounds height\="99" width\="118" x\="19" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="3188" endstart\="3166" start\="3089" startend\="3138"/>\r\n<bounds height\="99" width\="118" x\="295" y\="17"/>\r\n</element>\r\n<element type\="service-activator">\r\n<structure end\="3293" endstart\="3293" start\="3191" startend\="3293"/>\r\n<bounds height\="100" width\="118" x\="157" y\="17"/>\r\n</element>\r\n</graph>
|
||||
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-batch-integration/src/test/resources/org/springframework/batch/integration/chunk/RemoteChunkFaultTolerantStepJmsIntegrationTests-context.xml=<?xml version\="1.0" encoding\="UTF-8"?>\r\n<graph>\r\n<element type\="outbound-channel-adapter">\r\n<structure end\="2871" endstart\="2871" start\="2747" startend\="2871"/>\r\n<bounds height\="100" width\="155" x\="157" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="2910" endstart\="2910" start\="2873" startend\="2910"/>\r\n<bounds height\="99" width\="118" x\="19" y\="17"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="2949" endstart\="2949" start\="2912" startend\="2949"/>\r\n<bounds height\="99" width\="118" x\="19" y\="137"/>\r\n</element>\r\n<element type\="transformer">\r\n<structure end\="3070" endstart\="3070" start\="2952" startend\="3070"/>\r\n<bounds height\="100" width\="155" x\="157" y\="137"/>\r\n</element>\r\n<element type\="channel">\r\n<structure end\="4339" endstart\="4317" start\="3541" startend\="3590"/>\r\n<bounds height\="99" width\="118" x\="332" y\="137"/>\r\n</element>\r\n<element type\="interceptors">\r\n<structure end\="4315" endstart\="4288" start\="3617" startend\="3643"/>\r\n<bounds height\="53" width\="1" x\="468" y\="129"/>\r\n</element>\r\n</graph>
|
||||
eclipse.preferences.version=1
|
||||
|
||||
@@ -63,12 +63,28 @@
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-dbcp</groupId>
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-core</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-jdbc</artifactId>
|
||||
<version>${spring.integration.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-jms</artifactId>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.springframework.batch.integration.chunk;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameter;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class RemoteChunkFaultTolerantStepJdbcIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncher jobLauncher;
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel replies;
|
||||
|
||||
@Before
|
||||
public void drain() {
|
||||
Message<?> message = replies.receive(100L);
|
||||
while (message!=null) {
|
||||
// System.err.println(message);
|
||||
message = replies.receive(100L);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedStep() throws Exception {
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
|
||||
new JobParameter("unsupported"))));
|
||||
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
|
||||
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(9, stepExecution.getReadCount());
|
||||
// In principle the write count could be more than 2 and less than 9...
|
||||
assertEquals(7, stepExecution.getWriteCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedStepOnError() throws Exception {
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
|
||||
new JobParameter("error"))));
|
||||
assertEquals(BatchStatus.FAILED, jobExecution.getStatus());
|
||||
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(9, stepExecution.getReadCount());
|
||||
// In principle the write count could be more than 2 and less than 9...
|
||||
assertEquals(7, stepExecution.getWriteCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSunnyDayFaultTolerant() throws Exception {
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParameters(Collections.singletonMap("item.three",
|
||||
new JobParameter("3"))));
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(9, stepExecution.getReadCount());
|
||||
assertEquals(9, stepExecution.getWriteCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipsInWriter() throws Exception {
|
||||
JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder().addString("item.three", "fail")
|
||||
.addLong("run.id", 1L).toJobParameters());
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(9, stepExecution.getReadCount());
|
||||
assertEquals(7, stepExecution.getWriteCount());
|
||||
// The whole chunk gets skipped...
|
||||
assertEquals(2, stepExecution.getWriteSkipCount());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Default database platform is HSQLDB:
|
||||
batch.jdbc.driver=org.hsqldb.jdbcDriver
|
||||
batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true
|
||||
# Override and use this one in for a separate server process so you can inspect
|
||||
# the results (or add it to system properties with -D to override at run time).
|
||||
# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples
|
||||
batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer
|
||||
batch.schema.script=classpath*:/org/springframework/batch/core/schema-hsqldb.sql
|
||||
batch.drop.script=classpath*:/org/springframework/batch/core/schema-drop-hsqldb.sql
|
||||
integration.schema.script=classpath*:/org/springframework/integration/jdbc/schema-hsqldb.sql
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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:beans="http://www.springframework.org/schema/beans" xmlns:integration="http://www.springframework.org/schema/integration"
|
||||
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<job id="job" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="step">
|
||||
<tasklet>
|
||||
<chunk reader="reader" writer="writer" commit-interval="2" skip-limit="2">
|
||||
<skippable-exception-classes>
|
||||
<include class="java.lang.IllegalStateException" />
|
||||
</skippable-exception-classes>
|
||||
</chunk>
|
||||
</tasklet>
|
||||
</step>
|
||||
</job>
|
||||
|
||||
<bean id="reader" class="org.springframework.batch.integration.chunk.TestItemReader" scope="step">
|
||||
<property name="items">
|
||||
<list>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>#{jobParameters['item.three']}</value>
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
<value>6</value>
|
||||
<value>7</value>
|
||||
<value>8</value>
|
||||
<value>9</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="writer" class="org.springframework.batch.integration.chunk.TestItemWriter" />
|
||||
|
||||
<bean id="chunkWriter" class="org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter" scope="step">
|
||||
<property name="messagingOperations" ref="messagingGateway" />
|
||||
<property name="replyChannel" ref="replies" />
|
||||
<property name="maxWaitTimeouts" value="10" />
|
||||
</bean>
|
||||
|
||||
<bean id="messagingGateway" class="org.springframework.integration.core.MessagingTemplate">
|
||||
<property name="defaultChannel" ref="requests" />
|
||||
<property name="receiveTimeout" value="1000" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
|
||||
<property name="scopes">
|
||||
<map>
|
||||
<entry key="thread">
|
||||
<bean class="org.springframework.context.support.SimpleThreadScope" />
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<int-jdbc:message-store id="messageStore" data-source="dataSource"/>
|
||||
|
||||
<integration:channel id="requests">
|
||||
<integration:queue message-store="messageStore" />
|
||||
</integration:channel>
|
||||
<integration:channel id="replies">
|
||||
<integration:queue message-store="messageStore" />
|
||||
</integration:channel>
|
||||
<integration:service-activator input-channel="requests" output-channel="replies" ref="chunkHandler">
|
||||
<integration:poller>
|
||||
<integration:interval-trigger interval="100" />
|
||||
<integration:transactional />
|
||||
</integration:poller>
|
||||
</integration:service-activator>
|
||||
|
||||
<bean id="chunkHandler" class="org.springframework.batch.integration.chunk.RemoteChunkHandlerFactoryBean">
|
||||
<property name="chunkWriter" ref="chunkWriter" />
|
||||
<property name="step" ref="step" />
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
|
||||
<property name="driverClassName" value="${batch.jdbc.driver}" />
|
||||
<property name="url" value="${batch.jdbc.url}" />
|
||||
<property name="username" value="${batch.jdbc.user}" />
|
||||
<property name="password" value="${batch.jdbc.password}" />
|
||||
<property name="testWhileIdle" value="${batch.jdbc.testWhileIdle}" />
|
||||
<property name="validationQuery" value="${batch.jdbc.validationQuery}" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<context:property-placeholder location="classpath:config-${ENVIRONMENT:hsql}.properties"
|
||||
system-properties-mode="OVERRIDE" ignore-resource-not-found="true" ignore-unresolvable="true" />
|
||||
|
||||
<!-- Initialise the database if enabled: -->
|
||||
<jdbc:initialize-database data-source="dataSource" enabled="${batch.data.source.init}"
|
||||
ignore-failures="DROPS">
|
||||
<jdbc:script location="${batch.drop.script}" />
|
||||
<jdbc:script location="${batch.schema.script}" />
|
||||
<jdbc:script location="${integration.schema.script}" />
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<batch:job-repository id="jobRepository" />
|
||||
|
||||
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
|
||||
<property name="jobRepository" ref="jobRepository" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user