RESOLVED - BATCH-952: StagingItemReader is not restartable

introduced ProcessIndicatorItemWrapper (includes id) and StagingItemProcessor (marks processed inputs) to achieve restartability for parallelJob
This commit is contained in:
robokaso
2009-01-15 12:06:51 +00:00
parent 4f273334d1
commit 8e41bc5603
5 changed files with 118 additions and 20 deletions

View File

@@ -65,15 +65,20 @@ public class StagingItemReaderTests {
@Transactional
@Test
public void testReaderUpdatesProcessIndicator() throws Exception {
public void testReaderWithProcessorUpdatesProcessIndicator() throws Exception {
long id = simpleJdbcTemplate.queryForLong("SELECT MIN(ID) from BATCH_STAGING where JOB_ID=?", jobId);
String before = simpleJdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?",
String.class, id);
assertEquals(StagingItemWriter.NEW, before);
String item = reader.read();
ProcessIndicatorItemWrapper<String> wrapper = reader.read();
String item = wrapper.getItem();
assertEquals("FOO", item);
StagingItemProcessor<String> updater = new StagingItemProcessor<String>();
updater.setJdbcTemplate(simpleJdbcTemplate);
updater.process(wrapper);
String after = simpleJdbcTemplate.queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?",
String.class, id);
@@ -89,7 +94,7 @@ public class StagingItemReaderTests {
txTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus transactionStatus) {
try {
testReaderUpdatesProcessIndicator();
testReaderWithProcessorUpdatesProcessIndicator();
}
catch (Exception e) {
fail("Unxpected Exception: " + e);
@@ -118,8 +123,8 @@ public class StagingItemReaderTests {
String.class, id);
assertEquals(StagingItemWriter.NEW, before);
Object item = reader.read();
assertEquals("FOO", item);
ProcessIndicatorItemWrapper<String> wrapper = reader.read();
assertEquals("FOO", wrapper.getItem());
transactionStatus.setRollbackOnly();