I’ve inherited a Spring Batch job & am trying to understand the following behavior.
An exception was thrown in the configIBMTCompletionProcessor
(ConfigIBMTCompletionProcessor.java
)
of the VerifyPreditErrors
step, & I’m expecting the job to stop as per the step definition. But this step was marked as ABANDONED
& proceeded to the next step IBMTFileCopy
.
XML Steps Definition
<batch:step id="VerifyPreditErrors">
<batch:tasklet>
<batch:chunk reader="iinnoOpReader" writer="compositeIBMTCompletionWriter" processor="configIBMTCompletionProcessor"
commit-interval="1">
</batch:chunk>
</batch:tasklet>
<batch:next on="FAILED" to="IBMTFileCopy"/>
<batch:next on="SUCCESS" to="IBMTFetchDataCreateReport"/>
<batch:end on="NOOP"/>
<batch:listeners>
<batch:listener ref ="configIBMTCompletionWriter"></batch:listener>
</batch:listeners>
</batch:step>
<batch:step id="IBMTFileCopy" >
<batch:tasklet ref="fileCopyTasklet">
</batch:tasklet>
</batch:step>
XML Beans Definition
<bean id="compositeIBMTCompletionWriter" class="org.springframework.batch.item.support.CompositeItemWriter" scope="job">
<property name="delegates">
<list>
<ref bean="configIBMTCompletionWriter" /> <!-- This will update the tables if no pre-edit errors, otherwise send an email -->
<ref bean="flatFileItemWriterWrapper" /> <!-- This will create a file only if pre-edit errors are found. -->
</list>
</property>
</bean>
<bean id="configIBMTCompletionProcessor" class="com.companyName.coreconfig.batch.processor.ConfigIBMTCompletionProcessor" />
<bean id="configIBMTCompletionWriter" class="com.companyName.coreconfig.batch.writer.IBMTCompletionWriter" scope="step">
<property name="fileName" value="IBMT_ERR_RPT_#{jobParameters[dt]}.csv"/>
</bean>
Java definition
configIBMTCompletionWriter bean (ConfigIBMTCompletionWriter.java)
public class ConfigIBMTCompletionWriter implements ItemWriter<List<CustomParams>>,
StepExecutionListener {
@Override
public void write(List<? extends List<CustomParams>> items) throws Exception {
...
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
logger.info("Setting the step status as: " + status);
if (status.equals(Constants.SUCCESS)) {
return new ExitStatus(Constants.SUCCESS);
} else if (status.equals(Constants.FAILED)) {
return new ExitStatus(Constants.FAILED);
}
return ExitStatus.NOOP;
}
@Override
public void beforeStep(StepExecution stepExecution) {}
}
configIBMTCompletionProcessor bean (ConfigIBMTCompletionProcessor.java)
public class ConfigIBMTCompletionProcessor implements
ItemProcessor<String, List<CustomParams>>, StepExecutionListener {
// fetch data from DB
String status = service.fetchBatchWorkStatus();
case (status) {
...
case Constants.FAILED:
throw Exception(...);
...
}
}
@Override
public void beforeStep(StepExecution stepExecution) {
// some pre-processing
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
// TODO Auto-generated method stub
return null;
}
Attached is a picture of the Batch job’s step details:
Questions
-
Why did the job proceed to the IBMTFileCopy step?
-
Why is the VerifyPreditErrors marked as ABANDONED?