0

我正在使用 spring batch 和 spring batch admin 来进行我们的日常批处理工作。我已经通过 spring 批处理管理 UI 启动作业,使用 tomcat 7 对其进行了测试。

我的工作有跨不同服务器运行的远程分区步骤,我使用 rabbitmq 作为中间件,用于远程分区的 spring 批处理集成。

在测试时,我在所有服务器上部署应用程序,在所有服务器上启动 tomcat,以便启动所有侦听器(入站网关并发线程),启动所有 bean。

现在我想将它转移到生产中,所以想将它添加到 cron 中,它应该在每天凌晨 4 点自动启动作业。

1) 有没有办法使用 cron 启动工作?

2)在这种情况下,我们是否需要在所有服务器上启动tomcat,或者它可以在没有它的情况下运行?

3)如果我在一台服务器(主服务器)上启动作业,如何在所有服务器上启动 bean、消费者等,以便步骤将作为分区步骤在所有服务器上运行?

在 spring 批处理管理示例中,在 launch-context.xml 中有

<description><![CDATA[
  A convenient aggregating config file for running the jobs in this project
  from the command line instead of from the web application.  E.g.

  $ MAVEN_OPTS="-Dbatch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples -Dbatch.data.source.init=false" \
    mvn exec:java -Dexec.classpathScope=runtime \
    -Dexec.mainClass=org.springframework.batch.core.launch.support.CommandLineJobRunner \
    -Dexec.args="classpath:launch-context.xml job1 fail=false run.id=1"


  ]]>
</description>

<import resource="classpath*:/META-INF/spring/batch/bootstrap/**/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/override/**/*.xml" />

<bean id="jobLauncherTaskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/>

我可以将它用于我的用例吗?

4

1 回答 1

1

该进程需要在所有服务器上运行。

一种解决方案是继续使用 Tomcat(并让它们一直运行)。spring-batch-admin您可以使用的 ReST API启动批处理作业(例如使用curlfrom cron)。

Spring XD 项目(即将发布)还提供了用于启动批处理作业的 ReST API 。

于 2014-07-14T13:03:44.043 回答