简体   繁体   中英

Quartz JobExecutionContext not persisting when run in terracotta jobstore

I would like to persist retry count data across Triggers which are running same job.

I tried storing it in to JobExectionContext.JobDetails.JobDataMap, which is a DirtyHashMap. It gets stored but when second time the same job run by different Trigger and if that trigger update value of same key it does not persist. So, when you access it third time key value is still the same as first one.

Note: It does work when I run it normally and not in terracotta, using @PersistJobDataAfterExecution on Job class

Here is a pseudo code:

Cron Trigger 1: On CronTrigger.executionComplete() > if failed > increment retryCount and set it in jobcontext JobDataMap > reschedule same job with new SimpleTrigger (Retry count in context 0, new value set 1)

Simple Trigger 1: On SimpleTrigger.executionComplete() > if failed > increment retryCount and set it in jobcontext JobDataMap > reschedule same job with new SimpleTrigger (Retry count in context 1, new value set 2)

Simple Trigger 2: On SimpleTrigger.executionComplete() > if failed > increment retryCount and set it in jobcontext JobDataMap > reschedule same job with new SimpleTrigger

(Retry count in context is still 1, new value set 2)

This is where the problem is, Retry count is not incrementing after its set first time. Again this only happens if run in terracotta jobstore. Persist perfectly in single instance.

Any Idea?

I have found the solution which might help some one with similar issue. The problem was my terracotta version is 3.5.2 which do not support quartz 2 and above. So @PersistJobDataAfterExecution did not work. So I implemented deprecated StatefulJob interface and it worked like a charm!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM