如何在春天用多个Job映射相同的步骤

时间:2015-05-18 11:57:39

标签: spring-batch

我正在研究弹簧批处理模块,用例是,我们有下面提到的步骤列表。这些步骤被视为全球步骤。现在,这些步骤需要按照客户的基础进行映射。例如,对于客户来说,唯一的步骤是“批量上传”,“银行终端验证”,“合并外部交易,外部交易”等。需要运行。并且对于客户b' batchUploadStep',' externalTransactionMatching,' incorpatesExternalTransactionData'需要运行等等。有没有有效的方法可以做到这一点。在此示例中,processBatch id bean与一个调用jobluncher的batchService一起自动装配。

JobExecution jobExecution = jobLauncher.run(processBatch, getBatchJobParameters(batch));
            log.info("Process Batch Job execution {} ", jobExecution); 

这里我不想改变上面的代码。我想我们需要为不同的客户实现逻辑。

<job id="processBatch" xmlns="http://www.springframework.org/schema/batch" parent="abstractAggregatorBatch">
        <step id="batchUpload" next="bankTerminalValidation">
            <tasklet ref="batchUploadStep" allow-start-if-complete="true">
                <transaction-attributes timeout="#{batchTransactionTimeout}"/>
            </tasklet>
        </step>
        <step id="bankTerminalValidation" next="incorporateStagedExternalTransactionsIntoExternalTransaction">
            <tasklet ref="bankTerminalValidationStep" allow-start-if-complete="true">
                <transaction-attributes timeout="300"/>             
            </tasklet>
        </step>
        <step id="incorporateStagedExternalTransactionsIntoExternalTransaction" next="externalTransactionMatching">
            <tasklet ref="incorporateStagedExternalTransactionsIntoExternalTransactionStep" allow-start-if-complete="true">
                <transaction-attributes timeout="#{batchTransactionTimeout}"/>
            </tasklet>
        </step>
        <step id="externalTransactionMatching" next="incorporateExternalTransactionData">
            <tasklet ref="externalTransactionMatchingStep" allow-start-if-complete="true"/>
        </step>
        <step id="incorporateExternalTransactionData" next="extraBatchTransactionCheck">
            <tasklet ref="incorporateExternalTransactionDataStep"/>
        </step>
        <step id="extraBatchTransactionCheck" next="bankChargeValidation">
            <tasklet ref="extraBatchTransactionCheckStep"/>
        </step>
        <step id="bankChargeValidation" next="pineChargeCalculation" parent="abstractAggregatorStep">
            <tasklet task-executor="asyncExecutor" throttle-limit="${threadpool.coresize}">
                <chunk commit-interval="1" reader="uniqueFeeStructureIdReader" writer="bankChargeValidationItemWriter">
                    <listeners>
                        <listener ref="batchContextListener"/>
                    </listeners>
                </chunk>
                <transaction-attributes timeout="#{batchTransactionTimeout}"/>
            </tasklet>
            <listeners merge="true">
                <listener ref="bankChargeValidationStepExecutionListener"/>
            </listeners>
        </step>
        <step id="pineChargeCalculation" next="bankMprReconGeneration" parent="abstractAggregatorStep">
            <tasklet task-executor="asyncExecutor" throttle-limit="${threadpool.coresize}">
                <chunk commit-interval="1" reader="uniqueAggregatorMerchantIdReader" writer="pineChargeCalculationItemWriter">
                    <listeners>
                        <listener ref="batchContextListener"/>
                    </listeners>
                </chunk>
                <transaction-attributes timeout="#{batchTransactionTimeout}"/>
            </tasklet>
            <listeners merge="true">
                <listener ref="pineChargeCalculationStepExecutionListener"/>
            </listeners>
        </step>
        <step id="bankMprReconGeneration">
            <tasklet ref="bankMprReconGenerationStep">
                <transaction-attributes timeout="#{batchTransactionTimeout}"/>
            </tasklet>
        </step>
    </job>  

有人可以帮助我如何实现这个目标。

0 个答案:

没有答案