页脚回调未被调用

时间:2013-12-18 15:51:07

标签: spring-batch

我已定义了footercallback,但页脚信息未写入文件。 这是配置和代码。我错过了什么吗? 调用后脚步并将WriteCount写入日志但不写入文件。 工作def:

<job id="sodfeed" job-repository="tplJobRepository" xmlns="http://www.springframework.org/schema/batch">

    <step id="readWriteBalances">
        <tasklet>
        <chunk reader="balancesReader" writer="balancesWriter"  commit-interval="100" >

        </chunk>    
            <listeners>
                <listener ref="tplBatchFooterCallback" />
                <listener ref="tplBatchFailureListener" />
            </listeners>


        </tasklet>
    </step>
</job>

public class FooterCallback extends StepExecutionListenerSupport implements FlatFileFooterCallback{

private StepExecution stepExecution;
public void writeFooter(Writer writer) throws IOException {
    writer.write("EOF" + stepExecution.getWriteCount());
    System.out.println("**************************EOF" + stepExecution.getWriteCount());
}
  public ExitStatus afterStep(StepExecution stepExecution) {
    ExitStatus returnStatus = stepExecution.getExitStatus();
  logger.info("Number of records written:"+stepExecution.getWriteCount());

    return returnStatus;
 }
}

1 个答案:

答案 0 :(得分:0)

tplBatchFooterCallback正确注入了FlatFileItemWriter吗?听众和回调以不同的方式使用。

查找official javadoc