Skip to content

can not use properties validateOnCheckout #281

Closed

Description

@zhuangjiaju

when i use C3p0PoolingConnectionProvider it default use ComboPooledDataSource 。
at StdSchedulerFactory line 1392
private void populateProviderWithExtraProps(PoolingConnectionProvider cp, Properties props) throws Exception { Properties copyProps = new Properties(); copyProps.putAll(props); // Remove all the default properties first (they don't always match to setter name, and they are already // been set!) copyProps.remove(PoolingConnectionProvider.DB_DRIVER); copyProps.remove(PoolingConnectionProvider.DB_URL); copyProps.remove(PoolingConnectionProvider.DB_USER); copyProps.remove(PoolingConnectionProvider.DB_PASSWORD); copyProps.remove(PoolingConnectionProvider.DB_MAX_CONNECTIONS); copyProps.remove(PoolingConnectionProvider.DB_VALIDATION_QUERY); props.remove(PoolingConnectionProvider.POOLING_PROVIDER); setBeanProps(cp.getDataSource(), copyProps); }

"copyProps" not remove properties "validateOnCheckout",but ComboPooledDataSource don't have this properties ,lead to Exception
Caused by: java.lang.NoSuchMethodException: No setter for property 'validateOnCheckout' at org.quartz.impl.StdSchedulerFactory.setBeanProps(StdSchedulerFactory.java:1447) ~[quartz-2.3.0.jar:na] at org.quartz.impl.StdSchedulerFactory.populateProviderWithExtraProps(StdSchedulerFactory.java:1405) ~[quartz-2.3.0.jar:na] at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1040) ~[quartz-2.3.0.jar:na] ... 74 common frames omitted

Activity

  1. zemian commented on Dec 7, 2018

    @zemian
    Contributor

    What's your quartz.properties like on configuring these datasource?

  2. zemian commented on Dec 28, 2018

    @zemian
    Contributor

    Close as not an issue

  3. zhuangjiaju commented on Dec 28, 2018

    @zhuangjiaju
    Author

    I'm sorry that I didn't see your reply recently.
    My quartz.properties is as follows:

    Properties prop = new Properties();
            // scheduler实例名称 随便取
            prop.put("quartz.scheduler.instanceName", "DefaultQuartzScheduler");
            // scheduler实例的标志id,必须是全局唯一的,即使在集群环境中”逻辑”相同的scheduler。 或者可以使用“SYS_PROP”通过系统属性设置id。
            prop.put("org.quartz.scheduler.instanceId", "AUTO");
            // 建议设置为“org.terracotta.quartz.skipUpdateCheck=true”不会在程序运行中还去检查quartz是否有版本更新
            prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
    
            // jobStore
            prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
            prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.StdJDBCDelegate");
            // 使用哪个datasource
            prop.put("org.quartz.jobStore.dataSource", "freudDS");
            // 表前缀
            prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
            // 集群
            prop.put("org.quartz.jobStore.isClustered", "true");
            // #scheduler的checkin时间,时间长短影响failure scheduler的发现速度
            prop.put("org.quartz.jobStore.clusterCheckinInterval", "20000");
            prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "10");
            prop.put("org.quartz.jobStore.misfireThreshold", "20000");
            // 多线程
            prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
            prop.put("org.quartz.threadPool.threadCount", "50");
            prop.put("org.quartz.threadPool.threadPriority", "5");
            prop.put("org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread", "true");
    
            // 转换环境
            String environment = convertEnvironment(elasticJobQuartzJdbcConfigurer.getSystemEnvironment());
            // JDBC
            prop.put("org.quartz.dataSource.freudDS.driver", "com.mysql.jdbc.Driver");
            prop.put("org.quartz.dataSource.freudDS.URL", RESOURCE_BUNDLE.getString(environment + ".jdbc.url"));
            prop.put("org.quartz.dataSource.freudDS.user", RESOURCE_BUNDLE.getString(environment + ".jdbc.username"));
            prop.put("org.quartz.dataSource.freudDS.password", RESOURCE_BUNDLE.getString(environment + ".jdbc.password"));
            prop.put("org.quartz.dataSource.freudDS.maxConnections", "100");
            //数据源连接池,获取连接前先校验
            prop.put("org.quartz.dataSource.freudDS.validateOnCheckout", true);
            prop.put("org.quartz.dataSource.freudDS.validationQuery","select 'x'");
    
            prop.put("org.quartz.plugin.triggHistory.class", "org.quartz.plugins.history.LoggingJobHistoryPlugin");
            prop.put("org.quartz.plugin.shutdownhook.class", "org.quartz.plugins.management.ShutdownHookPlugin");
            prop.put("org.quartz.plugin.shutdownhook.cleanShutdown", "true");
            return prop;

    when i use

            prop.put("org.quartz.dataSource.freudDS.validateOnCheckout", true);

    there will be

    Caused by: java.lang.NoSuchMethodException: No setter for property 'validateOnCheckout' at org.quartz.impl.StdSchedulerFactory.setBeanProps(StdSchedulerFactory.java:1447) ~[quartz-2.3.0.jar:na] at org.quartz.impl.StdSchedulerFactory.populateProviderWithExtraProps(StdSchedulerFactory.java:1405) ~[quartz-2.3.0.jar:na] at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1040) ~[quartz-2.3.0.jar:na] ... 74 common frames omitted
  4. zhuangjiaju commented on Dec 28, 2018

    @zhuangjiaju
    Author

    Close as not an issue

    I'm sorry that I didn't see your reply recently.
    Please help to look at the problem again/

  5. zemian commented on Dec 28, 2018

    @zemian
    Contributor

    Hm... yeah, I think this might be a bug. I will look into it little more next time.

    For now, can you change "org.quartz.dataSource.freudDS.validateOnCheckout" to "org.quartz.dataSource.freudDS.testConnectionOnCheckin" and see if it works for you?

  6. reopened this on Dec 28, 2018
  7. zhuangjiaju commented on Dec 28, 2018

    @zhuangjiaju
    Author

    Hm... yeah, I think this might be a bug. I will look into it little more next time.

    For now, can you change "org.quartz.dataSource.freudDS.validateOnCheckout" to "org.quartz.dataSource.freudDS.testConnectionOnCheckin" and see if it works for you?

    I use

            prop.put("org.quartz.dataSource.freudDS.testConnectionOnCheckin", true);

    it is working .

    I want to contribute to open source code , and i will fix this issue and pull requests in a week . Please give me the opportunity ,Thank you!

  8. zemian commented on Dec 28, 2018

    @zemian
    Contributor

    Hi @fish7790714 That's great to hear. We welcome any contribution. And thanks for the PR!!!

  9. zemian commented on Dec 29, 2018

    @zemian
    Contributor

    I have accepted the PR against the master branch, but I still need to back port to other active older branches. Will close this after those are done.

  10. self-assigned this
    on Dec 29, 2018
  11. zemian commented on Dec 29, 2018

    @zemian
    Contributor

    Resolved ece2753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions