Spring Batch-提交间隔的后期绑定不适用于跳过策略 [英] Spring Batch - late binding of commit interval not working with skip policy

查看:190
本文介绍了Spring Batch-提交间隔的后期绑定不适用于跳过策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对块的commit-interval属性使用后期绑定.

I'm trying to use the late binding on the commit-interval attribute of a chunk.

当块中不包含skip-policy或retry-policy时,它可以正常工作,但是一旦添加了skip-policy(甚至是retry-policy),就不会考虑commit-interval并且批处理的工作方式就像将commit-interval设置为1.奇怪的是,当对commit-interval进行硬编码时,它可以正常工作...

When the chunk doesn't contain a skip-policy or retry-policy, it works fine but as soon as a skip-policy is added (or even a retry-policy), the commit-interval is not taken into account and the batch works as if the commit-interval is set to 1. The weird thing is, when the commit-interval is hard coded, it works fine...

因此,此配置可以正常工作:

So this configuration works fine :

<chunk reader="multiAccuseReceptionItemReader" 
                   processor="enrichissementPrescriptionItemProcessor"
                   writer="prescriptionItemWriter" 
                   commit-interval="#{jobExecutionContext['commits']}">

这个也很好:

<chunk reader="multiAccuseReceptionItemReader" 
                   processor="enrichissementPrescriptionItemProcessor"
                   writer="prescriptionItemWriter"
                   skip-policy="skipPolicy"
                   commit-interval="3">

但是这个没有考虑到commit-interval并将其设置为1:

But this one doesn't take into account the commit-interval and set it to 1 :

<chunk reader="multiAccuseReceptionItemReader" 
                   processor="enrichissementPrescriptionItemProcessor"
                   writer="prescriptionItemWriter"
                   skip-policy="skipPolicy"
                   commit-interval="#{jobExecutionContext['commits']}">

我尝试将completion-policy与simpleCompletionPolicy而不是commit-interval一起使用,但是更糟糕的是:当存在跳过策略或重试策略时,即使它是硬编码.在没有任何跳过策略或重试策略的情况下,不考虑chunkSize(硬编码或后期绑定).

I tried to use completion-policy with the simpleCompletionPolicy instead of the commit-interval, but it's even worse : when there is a skip-policy or a retry-policy, the chunkSize is not taken into account, even if it is hard coded. Without any skip-policy or retry-policy the chunkSize is taken into account (hard coded or late binding).

我正在使用Spring Batch 2.2.0(并且不能更改).

I'm using Spring Batch 2.2.0 (and can't change).

为什么这种行为? 如何动态设置带有跳过策略和重试策略的提交间隔?

Why this behavior? How can I dynamically set the commit-interval with a skip-policy and a retry-policy?

推荐答案

这是来自org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean类的spring-batch的已知错误:

It's a known bug of spring-batch from the class org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean : https://jira.spring.io/browse/BATCH-2096.

它已在2.2.2版中得到纠正.

It has been corrected in version 2.2.2.

所以最好的解决方案是升级到spring-batch v2.2.2(与2.2.0相同,但有一些错误更正).

So the best solution is to upgrade to v2.2.2 of spring-batch (which is the same as 2.2.0 with some bug corrections).

如果像我一样,您真的不能升级,那么最好的方法是从 git(标记2.2.2),将其添加到您的源代码中,并确保在类路径中的spring-batch-core jar之前加载您的源代码.

If -like me- you really can't upgrade, then the best way is to copy the class org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean from git (tag 2.2.2), add it to your sources and make sure that your sources are loaded before spring-batch-core jar in your classpath.

这篇关于Spring Batch-提交间隔的后期绑定不适用于跳过策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆