Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not use properties validateOnCheckout #281

Closed
zhuangjiaju opened this issue Nov 20, 2018 · 9 comments
Closed

can not use properties validateOnCheckout #281

zhuangjiaju opened this issue Nov 20, 2018 · 9 comments
Assignees

Comments

@zhuangjiaju
Copy link

zhuangjiaju commented Nov 20, 2018

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

@zemian
Copy link
Contributor

zemian commented Dec 7, 2018

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

@zemian
Copy link
Contributor

zemian commented Dec 28, 2018

Close as not an issue

@zemian zemian closed this as completed Dec 28, 2018
@zhuangjiaju
Copy link
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

@zhuangjiaju
Copy link
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/

@zemian
Copy link
Contributor

zemian commented Dec 28, 2018

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?

@zemian zemian reopened this Dec 28, 2018
@zhuangjiaju
Copy link
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!

@zemian
Copy link
Contributor

zemian commented Dec 28, 2018

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

@zemian
Copy link
Contributor

zemian commented Dec 29, 2018

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.

@zemian
Copy link
Contributor

zemian commented Dec 29, 2018

Resolved ece2753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants