org.quartz.impl.jdbcjobstore.JobStoreTX Java Examples
The following examples show how to use
org.quartz.impl.jdbcjobstore.JobStoreTX.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FebsJobConfigure.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean factory = new SchedulerFactoryBean(); // 设置数据源 DataSource job = dynamicRoutingDataSource.getDataSource("job"); factory.setDataSource(job); Properties prop = new Properties(); // 任务调度实例名称,集群时多个实例名称保持一致 prop.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, "FebsCloudScheduler"); // 任务调度实例ID,指定为AUTO时,将自动生成ID prop.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, StdSchedulerFactory.AUTO_GENERATE_INSTANCE_ID); // quartz提供的简单线程池,适用于绝大部分场景 prop.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class); // 并发执行任务的线程数,取决于服务器系统资源 prop.put("org.quartz.threadPool.threadCount", "20"); // 可以是Thread.MIN_PRIORITY(1)和Thread.MAX_PRIORITY(10)之间的任何int值 。 // 默认值为Thread.NORM_PRIORITY(5) prop.put("org.quartz.threadPool.threadPriority", "5"); // 指定任务存储策略,这里使用关系型数据库 prop.put(StdSchedulerFactory.PROP_JOB_STORE_CLASS, JobStoreTX.class); // 是否开启集群 prop.put("org.quartz.jobStore.isClustered", "true"); // 集群中任务调度实例失效的检查时间间隔,单位为毫秒 prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); prop.put("org.quartz.jobStore.misfireThreshold", "12000"); // 数据表前缀 prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); factory.setQuartzProperties(prop); factory.setSchedulerName("FEBS_Cloud_Scheduler"); // 延时启动 factory.setStartupDelay(1); factory.setApplicationContextSchedulerContextKey("applicationContextKey"); // 启动时更新己存在的 Job factory.setOverwriteExistingJobs(true); // 设置自动启动,默认为 true factory.setAutoStartup(true); return factory; }
Example #2
Source File: JobStoreJdbcProvider.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private JobStore createJobStore() { try { connectionProvider.initialize(); DBConnectionManager.getInstance().addConnectionProvider(QUARTZ_DS, connectionProvider); JobStoreTX delegate = new JobStoreTX(); delegate.setDataSource(QUARTZ_DS); delegate.setDriverDelegateClass(getDriverDelegateClass()); return delegate; } catch (Exception e) { log.error("Unable create job store", e); return null; } }
Example #3
Source File: OrientQuartzJdbcIT.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Before public void before() throws Exception { try (ODatabaseDocumentTx db = database.getInstance().acquire()) { OrientQuartzSchema.register(db); dbUrl = db.getURL(); } SimpleThreadPool threadPool = new SimpleThreadPool(3, Thread.NORM_PRIORITY); threadPool.initialize(); OrientConnectionProvider connProvider = new OrientConnectionProvider(); connProvider.setConnectionString(dbUrl); connProvider.setUser("admin"); connProvider.setPassword("admin"); connProvider.setUsePool(true); connProvider.setPoolMin(3); connProvider.setPoolMax(3); connProvider.initialize(); DBConnectionManager.getInstance().addConnectionProvider("orientDS", connProvider); DBConnectionManager.getInstance().getConnection("orientDS"); JobStoreTX jobStore = new JobStoreTX(); jobStore.setDataSource("orientDS"); jobStore.setDriverDelegateClass(OrientDelegate.class.getName()); DirectSchedulerFactory.getInstance().createScheduler("nexus", "1", threadPool, jobStore); scheduler = DirectSchedulerFactory.getInstance().getScheduler("nexus"); scheduler.clear(); scheduler.start(); }