如何在spring批处理中动态设置commit-interval

时间:2015-05-20 09:29:37

标签: java spring spring-batch

当我尝试将jobExecutioncontext中的值分配给commit-interval时,我收到以下错误。

<chunk reader="itemREader" writer="itemwriter" commit-interval="#{jobExecutionContext[rowcount]}">

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'jobExecutionContext' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'

从jobParameters中获取相同的错误。

通过创建扩展Si​​mpleCompletionPolicy并从jobExecutioncontext传递值的自定义策略类来尝试使用chunk-completion-policy。当我运行作业时,步骤已开始但未完成继续运行。

 <bean id="myCompletionPolicy"
          class="com.vn.src.service.myCompletionPolicy" scope="step">
        <property name="recordCount" value="#{jobExecutionContext[RowCount]}"/>
    </bean>

myCompletionPolicy类:

public class myCompletionPolicy extends SimpleCompletionPolicy {

    private String recordCount;

    public MapCpeBatchFileJobCompletionPolicy() {

        setChunkSize(Integer.valueOf(recordCount));

    }

    public void setRecordCount(String recordCount) {
        this.recordCount = recordCount;
    }
}

有人可以告诉我怎样才能动态设置commit-interval值?感谢。

0 个答案:

没有答案