【问题标题】:Spring batch, where/how to save the metadata about jobsSpring批处理,在哪里/如何保存有关作业的元数据
【发布时间】:2018-12-16 02:14:44
【问题描述】:

如何设置任何外部数据库(mysql、postgres,我现在不关心哪个)以用于元数据?

目前我有春季批量将作业结果写入 Mongodb 并且工作正常,但我没有跟踪作业状态,因此即使中途中断,作业每次都从头开始运行。

有很多示例说明如何避免这样做,但似乎无法找到明确的答案,说明我需要配置哪些内容才能将元数据发送到真实的地方而不是内存中。

我尝试添加属性文件,但没有效果

#    for Postgres:
batch.jdbc.driver=org.postgresql.Driver
batch.jdbc.url=jdbc:postgresql://localhost/postgres
batch.jdbc.user=postgres
batch.jdbc.password=mysecretpassword
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.sql
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgresql.sql
batch.jdbc.testWhileIdle=false
batch.jdbc.validationQuery=

【问题讨论】:

    标签: spring spring-batch


    【解决方案1】:

    有很多示例说明如何避免这样做,但似乎无法找到明确的答案,说明我需要配置什么才能将元数据发送到真实的地方而不是内存中。

    您需要在批处理应用程序上下文中配置 DataSource 类型的 bean(或扩展 DefaultBatchConfigurer 并设置要用于存储元数据的数据源)。

    这里有很多样例:https://github.com/spring-projects/spring-batch/tree/master/spring-batch-samples

    您可以在这里找到数据源配置:https://github.com/spring-projects/spring-batch/blob/master/spring-batch-samples/src/main/resources/data-source-context.xml

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-20
      相关资源
      最近更新 更多