简体   繁体   English

Spring Batch多个作业执行

[英]Spring Batch Multiple Job execution

I am using a spring batch tasklet for batch processing and my scenario is to do the below process once in a day at say 11 PM in the night. 我正在使用Spring Batch Tasklet进行批处理,我的情况是每天晚上晚上11点执行一次以下过程。 The process are 该过程是

Read a file and process 读取文件并处理

write the data to the DB 将数据写入数据库

archive the file. 存档文件。

But when I execute the job, the job keeps on executing the first step in multiple threads and iam getting this error Could not execute the job succesfullyorg.springframework.batch.core.repository.JobExecutionAlreadyRunningException: 但是,当我执行该作业时,该作业会继续在多个线程中执行第一步,并且会出现此错误。无法成功执行该作业org.springframework.batch.core.repository.JobExecutionAlreadyRunningException:

Is there any wat that I can configure in my job xml to execute the job only once for the schedule time. 我可以在我的作业xml中配置任何wat,以在计划时间内仅执行一次作业。

<batch:job id="PullJob">


        <batch:step id="ProcessingStep" next="cleanStep">
            <batch:tasklet transaction-manager="transactionManager">
                <batch:chunk reader="fileReader" processor="processor" writer="dbWriter" commit-interval="30" />
            </batch:tasklet>
        </batch:step>

        <batch:step id="cleanStep">
            <tasklet ref="cleaningTasklet"/>
        </batch:step>

    </batch:job>

See this SO post. 请参阅此SO帖子。 If you have no other parameters you can pass in the current date as a parameter to get unique job executions. 如果没有其他参数,则可以传入当前日期作为参数以获取唯一的作业执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM