我们可以创建同一个java(spring)批处理作业的多个实例吗? [英] Can we create multiple instances of a same java(spring) batch job?

查看:397
本文介绍了我们可以创建同一个java(spring)批处理作业的多个实例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用quartz来安排弹簧批处理作业。

I am using quartz to schedule a spring batch job.

作业从一个文件夹(有多个文件)读取一个文件进行一些处理,并将其复制到另一个文件夹。

The job reads a file from a folder( which has multiple files ) does some processing and copies it to another folder.

可以创建作业的多个实例,并行运行,读取多个文件?

is it possible to create multiple instances of the job, that will run concurrenty,reading multiple files ?

我的问题是:

在春季批处理中,是否可以生成同一作业的多个实例?我使用石英schedular?

推荐答案

在Spring Batch中,每个 jobLauncher.run()调用的不同 JobParameters 在您的Spring配置中的jobLauncher 会在单独的线程中生成每个作业,如果它配置了适当的任务执行器:

In Spring Batch it is possible to start several jobs, provided you have supplied different JobParameters for each jobLauncher.run() call. jobLauncher in your Spring configuration will spawn each job in a separate thread, if it is configured with appropriate task executor:

<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    <property name="jobRepository" ref="jobRepository" />
    <property name="taskExecutor" ref="taskExecutor" />
</bean>

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"
    p:corePoolSize="5"
    p:maxPoolSize="30" />

这篇关于我们可以创建同一个java(spring)批处理作业的多个实例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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