BATCH-1189: By default, all exceptions should be fatal

This commit is contained in:
dhgarrette
2009-04-01 21:22:43 +00:00
parent 3f7f2d8b4e
commit 3dc92be2ed
8 changed files with 132 additions and 43 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ItemStreamSupport;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.WriteFailedException;
import org.springframework.batch.sample.domain.trade.Trade;
import org.springframework.batch.sample.domain.trade.TradeDao;
import org.springframework.util.Assert;
@@ -58,7 +59,7 @@ public class TradeWriter extends ItemStreamSupport implements ItemWriter<Trade>
Assert.notNull(trade.getPrice()); // There must be a price to total
if (this.failingCustomers.contains(trade.getCustomer())) {
throw new RuntimeException("Something unexpected happened!");
throw new WriteFailedException("Something unexpected happened!");
}
}

View File

@@ -17,7 +17,11 @@
processor="creditIncreaseProcessor"
writer="hibernateCreditWriter"
skip-limit="5"
commit-interval="3"/>
commit-interval="3">
<skippable-exception-classes>
java.lang.RuntimeException
</skippable-exception-classes>
</chunk>
</tasklet>
</step>
</job>

View File

@@ -17,6 +17,10 @@
<tasklet>
<chunk reader="fileItemReader" processor="tradeProcessor" writer="tradeWriter"
commit-interval="3" skip-limit="10">
<skippable-exception-classes>
org.springframework.batch.item.file.FlatFileParseException
org.springframework.batch.item.WriteFailedException
</skippable-exception-classes>
</chunk>
</tasklet>
@@ -46,7 +50,7 @@
<tasklet>
<chunk writer="itemTrackingWriter">
<skippable-exception-classes merge="true">
java.lang.RuntimeException
org.springframework.batch.item.validator.ValidationException
</skippable-exception-classes>
</chunk>
</tasklet>
@@ -59,7 +63,7 @@
<chunk reader="tradeSqlItemReader" processor="tradeProcessor" writer="dummyWriter"
commit-interval="2" skip-limit="10">
<skippable-exception-classes>
org.springframework.batch.item.validator.ValidationException
java.lang.RuntimeException
</skippable-exception-classes>
</chunk>
</tasklet>