【问题标题】:Spring boot Apache Camel Quartz JDBC schedulerSpring Boot Apache Camel Quartz JDBC 调度程序
【发布时间】:2019-11-28 08:20:36
【问题描述】:

我将 spring boot 与 apache camel 一起使用,并且我想创建石英调度程序,但是当我使用此配置时没有发生任何事情:

camel:
    component:
        quartz2:
          properties:
            org:
              quartz:
                scheduler:
                  instanceName: ClusteredSchedular
                  instanceId: AUTO
                threadPool:
                  class: org.quartz.simpl.SimpleThreadPool
                  threadCount: 25
                  threadPriority: 5
                jobStore:
                  class: org.quartz.impl.jdbcjobstore.JobStoreTX
                  driverDelegateClass: org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
                  dataSource: quartz
                  isClustered: true
                  clusterCheckinInterval: 20000
                dataSource:
                  quartz:
                    driver: oracle.jdbc.driver.OracleDriver
                    URL: jdbc:oracle:thin:@localhost:1521:xe
                    user: test
                    password: test
                    maxConnections: 5
                    validationQuery: select 1 from dual

有谁知道为什么这个配置不起作用? Camel 只能从默认配置中看到此配置

    org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 10
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

org.quartz.jobStore.misfireThreshold: 60000

org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore

【问题讨论】:

    标签: java spring spring-boot apache-camel quartz-scheduler


    【解决方案1】:

    我更喜欢使用 springboot 数据源来启用石英集群。

    spring:
      datasource:
        driver-class-name: org.postgresql.Driver
        url: jdbc:postgresql://127.0.0.1:5432/postgres
        username: postgres
        password: password
      quartz:
        scheduler-name: quartzSchedulernot work anymore
        jobStoreType: jdbc
        startup-delay: PT10S
        wait-for-jobs-to-complete-on-shutdown: true
      properties:
        org.quartz.scheduler.instanceId: AUTO
        org.quartz.scheduler.jmx.export: true
        org.quartz.threadPool.threadCount: 15
        org.quartz.threadPool.threadPriority: 5
        org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
        org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
        org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
        org.quartz.jobStore.tablePrefix: QRTZ_
        org.quartz.jobStore.isClustered: true
        org.quartz.jobStore.clusterCheckinInterval: 1000
    

    【讨论】:

    • 感谢您的回答,这将完美运行,但我为自动创建表石英添加了一个参数:job-store-type:jdbc jdbc:initialize-schema:always comment-prefix:'#'
    • 使用这样的配置我得到org.quartz.SchedulerConfigException: DataSource name not set. 异常。问题是它不接受 spring.jdbc.connections 中的(在我的情况下是多个)数据源
    • 如果你有多个数据源,你必须明确的配置石英以使用或其他
    • 在 SpringBoot 2.3.9 和 Camel 3.4.3 中,上面的配置似乎被忽略了,并且使用了默认的石英配置。对我有用的是指定:camel.component.quartz.properties-file=my-quartz.properties。但是我必须将我的 spring 数据源复制到这个文件中。示例: org.quartz.dataSource.myDS.driver = org.h2.Driver org.quartz.dataSource.myDS.URL = ...etc org.quartz.jobStore.dataSource=myDS 如果我可以参考春天就好了在 application.properties/yml 中配置的数据源(我有多个)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 2018-01-17
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多