quartz 注意事项

注意事项:

  1 scheduler.scheduleJob(jobDetail, trigger); 的时候, jobKey, triggerKey 都不能和数据库中已经存在的 冲突,否则就注册不上!!!。      2 scheduler.start(); 之后 , 数据库所有的 触发器 都会被扫描, 然后就工作了。   scheduler.start(); 之后,我们还可以进行注册,或者pause、resume等待,scheduler.start()只是启动了几个后台进程,   3 执行扫描、等任务的时候 ,会先判断是否有 空闲的线程,没有的话, 可能job 就得不得执行,!! 这可能是个大问题, 需要 急早发现, 设置更加到的线程数。 public int blockForAvailableThreads() { synchronized(nextRunnableLock) { while((availWorkers.size() < 1 || handoffPending) && !isShutdown) { try { nextRunnableLock.wait(500); } catch (InterruptedException ignore) { } } return availWorkers.size(); } }   4 获取锁的时候,会打印对应的线程, 18:33:05.554 [dufy_test_Worker-3] DEBUG o.q.i.jdbcjobstore.SimpleSemaphore - Lock 'TRIGGER_ACCESS' is desired by: dufy_test_Worker-3     5  有时候发现 数据库的几个表的数据, 全没有了! 不是bug!   因为   // 触发器类型 SimpleScheduleBuilder builder = SimpleScheduleBuilder // 设置执行次数 .repeatSecondlyForTotalCount(50);   所以, 执行完50次之后, 状态变成了 complete, 然后 几个trigger 表,以及 job_detail 表 的对应的job 、trigger 数据都被删除!!   最后 更新qrtz_TRIGGERS 一次时: 2021-07-25 18:57:52 | Time 0 ms | statement-0 | UPDATE qrtz_TRIGGERS SET JOB_NAME = 'job1_4', JOB_GROUP = 'jGroup1', DESCRIPTION = NULL, NEXT_FIRE_TIME = -1, PREV_FIRE_TIME = 1627210672201, TRIGGER_STATE = 'COMPLETE', TRIGGER_TYPE = 'SIMPLE', START_TIME = 1627210623201, END_TIME = 0, CALENDAR_NAME = NULL, MISFIRE_INSTR = 0, PRIORITY = 5 WHERE SCHED_NAME = 'dufy_test' AND TRIGGER_NAME = 'triggerser1_3' AND TRIGGER_GROUP = 'tGroudsgfsp1'   TRIGGER_STATE = 'COMPLETE' 所以就被删除了!     6 job 的blob 是什么? 是 JobDataMap 的序列化结果, 是job 的参数... 是 java 的ByteArrayOutputStream序列化, 效率可能比较低。。   7 MisfireHandler 大概是每30 s 执行一次... 18:53:28.196 [QuartzScheduler_dufy_test-NON_CLUSTERED_MisfireHandler] DEBUG o.q.impl.jdbcjobstore.JobStoreTX - Found 0 triggers that missed their scheduled fire-time. 2021-07-25 18:53:28 | Time 0 ms | commit-0 | 2021-07-25 18:53:49 | Time 0 ms | statement-0 | SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME, PRIORITY FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'dufy_test' AND TRIGGER_STATE = 'WAITING' AND NEXT_FIRE_TIME <= 1627210459052 AND (MISFIRE_INSTR = -1 OR (MISFIRE_INSTR != -1 AND NEXT_FIRE_TIME >= 1627210369052)) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC 2021-07-25 18:53:49 | Time 0 ms | commit-0 | 18:53:49.055 [dufy_test_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers 2021-07-25 18:54:13 | Time 0 ms | statement-0 | SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME, PRIORITY FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'dufy_test' AND TRIGGER_STATE = 'WAITING' AND NEXT_FIRE_TIME <= 1627210483983 AND (MISFIRE_INSTR = -1 OR (MISFIRE_INSTR != -1 AND NEXT_FIRE_TIME >= 1627210393983)) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC 2021-07-25 18:54:13 | Time 0 ms | commit-0 | 18:54:13.986 [dufy_test_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers 18:54:28.195 [QuartzScheduler_dufy_test-NON_CLUSTERED_MisfireHandler] DEBUG o.q.impl.jdbcjobstore.JobStoreTX - MisfireHandler: scanning for misfires... 2021-07-25 18:54:28 | Time 0 ms | statement-0 | SELECT COUNT(TRIGGER_NAME) FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'dufy_test' AND NOT (MISFIRE_INSTR = -1) AND NEXT_FIRE_TIME < 1627210408195 AND TRIGGER_STATE = 'WAITING' 18:54:28.197 [QuartzScheduler_dufy_test-NON_CLUSTERED_MisfireHandler] DEBUG o.q.impl.jdbcjobstore.JobStoreTX - Found 0 triggers that missed their scheduled fire-time. 2021-07-25 18:54:28 | Time 0 ms | commit-0 | 2021-07-25 18:54:38 | Time 1 ms | statement-0 | SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME, PRIORITY FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'dufy_test' AND TRIGGER_STATE = 'WAITING' AND NEXT_FIRE_TIME <= 1627210508759 AND (MISFIRE_INSTR = -1 OR (MISFIRE_INSTR != -1 AND NEXT_FIRE_TIME >= 1627210418759)) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC 2021-07-25 18:54:38 | Time 0 ms | commit-0 | 18:54:38.762 [dufy_test_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers 2021-07-25 18:55:05 | Time 0 ms | statement-0 | SELECT TRIGGER_NAME, TRIGGER_GROUP, NEXT_FIRE_TIME, PRIORITY FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'dufy_test' AND TRIGGER_STATE = 'WAITING' AND NEXT_FIRE_TIME <= 1627210535020 AND (MISFIRE_INSTR = -1 OR (MISFIRE_INSTR != -1 AND NEXT_FIRE_TIME >= 1627210445020)) ORDER BY NEXT_FIRE_TIME ASC, PRIORITY DESC 2021-07-25 18:55:05 | Time 0 ms | commit-0 |

上一篇:MYSQL数据库快速添加测试数据方法


下一篇:SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size