当前位置:网站首页>Quartz misfire missed and compensated execution
Quartz misfire missed and compensated execution
2022-07-06 03:15:00 【to. to】
Dispatch (scheduleJob) Or resume scheduling (resumeTrigger,resumeJob) The latter is different misfire Corresponding processing rules
misfire The condition for this is : By the time of the trigger execution, the previous execution has not been completed , And there are no idle threads in the thread pool to use ( Or there are idle threads that can be used, but job Set to @DisallowConcurrentExecution) And the expiration time has exceeded misfireThreshold Think of it as misfire 了 , Missed trigger
such as :13:07:24 Start execution , repeat 5 Time , At the beginning of execution ,quartz The time of each scheduling has been calculated , They are as follows :
03:33:36,03:33:39,03:33:42,03:33:45,03:33:48,03:33:51
If the first execution time is 11s, To 03:33:47 end ,03:33:47 subtract 03:33:39 The time interval is 8s, If misfireThreshold The set time is less than or equal to 8s interval , Think it is misfire 了 , If it is greater than 8s interval , I don't think so misfire.
CronTrigger
CronScheduleBuilder csb = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
csb.withMisfireHandlingInstructionDoNothing();
csb.withMisfireHandlingInstructionFireAndProceed();( Default )
csb.withMisfireHandlingInstructionIgnoreMisfires();
withMisfireHandlingInstructionDoNothing
—— Do not trigger immediate execution
—— Wait for the next time Cron When the trigger frequency reaches the time, it starts to follow Cron Frequency in turn
withMisfireHandlingInstructionIgnoreMisfires
—— Start execution immediately with the first missed frequency time
—— Redo all missed frequency cycles after
—— The occurrence time of the next trigger frequency is longer than the current time , Then follow the normal Cron Frequency in turn
withMisfireHandlingInstructionFireAndProceed( Default )
—— Trigger an execution immediately with the current time as the trigger frequency
—— And then according to Cron Frequency in turn
SimpleTrigger
SimpleScheduleBuilder ssb = SimpleScheduleBuilder.simpleSchedule();
ssb.withMisfireHandlingInstructionFireNow();
ssb.withMisfireHandlingInstructionIgnoreMisfires();
ssb.withMisfireHandlingInstructionNextWithExistingCount();
ssb.withMisfireHandlingInstructionNextWithRemainingCount();
ssb.withMisfireHandlingInstructionNowWithExistingCount(); ( Default )
ssb.withMisfireHandlingInstructionNowWithRemainingCount();
withMisfireHandlingInstructionFireNow
—— Trigger the execution immediately with the current time as the trigger frequency
—— To FinalTIme The number of remaining cycles
—— The period frequency based on the time of scheduling or recovery scheduling ,FinalTime According to the remaining times and the current time
—— Adjusted FinalTime It will be slightly greater than the basis starttime Calculated to FinalTime value
withMisfireHandlingInstructionIgnoreMisfires
—— Start execution immediately with the first missed frequency time
—— Redo all missed frequency cycles
—— The next trigger frequency occurs later than the current time , according to Interval And then the rest of the frequencies
—— In total RepeatCount+1 Time
withMisfireHandlingInstructionNextWithExistingCount
—— Do not trigger immediate execution
—— Wait for the next trigger frequency cycle , To FinalTime The number of remaining cycles
—— With startTime Calculate the cycle frequency for the reference , And get the FinalTime
—— Even if in the middle pause,resume Keep it up later FinalTime Time invariable
withMisfireHandlingInstructionNextWithRemainingCount
—— Do not trigger immediate execution
—— Wait for the next trigger frequency cycle , To FinalTime The number of remaining cycles
—— With startTime Calculate the cycle frequency for the reference , And get the FinalTime
—— Even if in the middle pause,resume Keep it up later FinalTime Time invariable
withMisfireHandlingInstructionNowWithExistingCount( Default )
—— Trigger the execution immediately with the current time as the trigger frequency
—— To FinalTIme The number of remaining cycles
—— The period frequency based on the time of scheduling or recovery scheduling ,FinalTime According to the remaining times and the current time
—— Adjusted FinalTime It will be slightly greater than the basis starttime Calculated to FinalTime value
withMisfireHandlingInstructionNowWithRemainingCount
—— Trigger the execution immediately with the current time as the trigger frequency
—— To FinalTIme The number of remaining cycles
—— The period frequency based on the time of scheduling or recovery scheduling ,FinalTime According to the remaining times and the current time
—— Adjusted FinalTime It will be slightly greater than the basis starttime Calculated to FinalTime value
MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
—— This instruction causes trigger Forget the original settings starttime and repeat-count
—— Trigger repeat-count Will be set to the number of times remaining
—— This will result in failure to obtain the original settings later starttime and repeat-count value
misfireHandler Threads
The following reasons may cause misfired job:
- The system was restarted for some reason . Between system shutdown and restart , Maybe some tasks will be misfire;
- Trigger Be suspended (suspend) For a while , Some tasks may be misfire;
- All threads in the thread pool are occupied , As a result, the task cannot be triggered to execute , cause misfire;
- Stateful tasks arrive at the next trigger time , The last execution is not over yet ; In order to deal with misfired job,Quartz In Chinese, it means trigger Defines the processing strategy , There are mainly the following two :MISFIRE_INSTRUCTION_FIRE_ONCE_NOW: in the light of misfired job Do it right now ;MISFIRE_INSTRUCTION_DO_NOTHING: Ignore misfired job, Wait for the next trigger ; The default is MISFIRE_INSTRUCTION_SMART_POLICY, The strategy is CronTrigger in =MISFIRE_INSTRUCTION_FIRE_ONCE_NOW Thread default 1 Once per minute ; In a transaction , The default is at most recovery 20 individual ;
Execute the process :
- If configured ( The default is true, Configurable ) Check whether it is necessary before acquiring the lock recovery Of trigger, First get misfireCount;
- obtain TRIGGER_ACCESS lock ;
- hasMisfiredTriggersInState: obtain misfired Of trigger, By default, a transaction can only have the largest 20 individual misfired trigger( Configurable ),misfired The basis of judgment :status=waiting,next_fire_time < current_time-misfirethreshold( Configurable , Default 1min)
- notifyTriggerListenersMisfired
- updateAfterMisfire: obtain misfire Strategy ( The default is MISFIRE_INSTRUCTION_SMART_POLICY, The strategy is CronTrigger in =MISFIRE_INSTRUCTION_FIRE_ONCE_NOW), Update according to policy nextFireTime;
- take nextFireTime Update to trigger surface ;
- commit connection, Release the lock
- If there are more misfired,sleep Short time ( For cluster load balancing ), otherwise sleep misfirethreshold Time , Continue polling after ;
misfireHandler The thread execution process is shown in the following figure :
边栏推荐
- tcpdump: no suitable device found
- Single instance mode of encapsulating PDO with PHP in spare time
- Analyze menu analysis
- 八道超经典指针面试题(三千字详解)
- 张丽俊:穿透不确定性要靠四个“不变”
- 【概念】Web 基础概念认知
- codeforces每日5題(均1700)-第六天
- 有没有完全自主的国产化数据库技术
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
- 【 kubernets series】 a Literature Study on the Safe exposure Applications of kubernets Service
猜你喜欢
Résumé des méthodes de reconnaissance des caractères ocr
Codeforces 5 questions par jour (1700 chacune) - jour 6
【 kubernets series】 a Literature Study on the Safe exposure Applications of kubernets Service
不赚钱的科大讯飞,投资价值该怎么看?
JS音乐在线播放插件vsPlayAudio.js
指针笔试题~走近大厂
Selenium share
Analyze menu analysis
Installation and use tutorial of cobaltstrike-4.4-k8 modified version
MySQL advanced notes
随机推荐
Leetcode problem solving -- 98 Validate binary search tree
Arabellacpc 2019 (supplementary question)
How to do function test well
Problems encountered in 2022 work IV
The next industry outlet: NFT digital collection, is it an opportunity or a foam?
Derivation of anti Park transform and anti Clarke transform formulas for motor control
ERA5再分析资料下载攻略
4. File modification
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
Single instance mode of encapsulating PDO with PHP in spare time
. Net 6 and Net core learning notes: Important issues of net core
银行核心业务系统性能测试方法
SD卡報錯“error -110 whilst initialising SD card
Custom attribute access__ getattribute__/ Settings__ setattr__/ Delete__ delattr__ method
Explore pointers and pointer types in depth
ASU & OSU | model based regularized off-line meta reinforcement learning
What is the investment value of iFLYTEK, which does not make money?
1.16 - 校验码
Computer graduation project asp Net fitness management system VS development SQLSERVER database web structure c programming computer web page source code project
NR modulation 1