Reputation: 11
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?
Upvotes: 1
Views: 938
Reputation: 11
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!
Upvotes: 0