我已经通读了几次spring批处理文档,并搜索了一种基于作业参数跳过作业步骤的方法。根据作业参数跳过步骤
例如说我有这个工作
<batch:job id="job" restartable="true"
xmlns="http://www.springframework.org/schema/batch">
<batch:step id="step1-partitioned-export-master">
<batch:partition handler="partitionHandler"
partitioner="partitioner" />
<batch:next on="COMPLETED" to="step2-join" />
</batch:step>
<batch:step id="step2-join">
<batch:tasklet>
<batch:chunk reader="xmlMultiResourceReader" writer="joinXmlItemWriter"
commit-interval="1000">
</batch:chunk>
</batch:tasklet>
<batch:next on="COMPLETED" to="step3-zipFile" />
</batch:step>
<batch:step id="step3-zipFile">
<batch:tasklet ref="zipFileTasklet" />
<!-- <batch:next on="COMPLETED" to="step4-fileCleanUp" /> -->
</batch:step>
<!-- <batch:step id="step4-fileCleanUp">
<batch:tasklet ref="fileCleanUpTasklet" />
</batch:step> -->
</batch:job>
我想如果需要,通过在作业PARAMATERS指定要能够跳过步骤4。
唯一有点相关的问题我能找到的how to select which spring batch job to run based on application argument - spring boot java config
这似乎表明,应该创建2对不同的工作环境和批处理步骤定义之外作出上述判决。
我已经按照这种模式,因为我有一个CSV文件导出以及XML作为例子。我将2个作业拆分为单独的spring-context.xml文件,每个导出类型一个,即使那里没有太多差异。
在这一点上,我虽然也许更清洁,因为我找不到替代品的例子。
但不必创建4个独立的情况下只是文件,以使其能够包括每个出口的情况下,第4步与否似乎有点疯狂。
我必须在这里失去了一些东西。