Do you have a recurring job that triggers every 5 minutes and only does a small check to see whether something needs to be processed? 95% of the time there is probably nothing to do and the job succeeds immediately. But, all these recurring jobs fill up your JobRunr Dashboard (a huge amount of succeeded and deleted jobs) and also fill up your database.
JobRunr already allows you to configure the deletion policy for all jobs in the JobRunr configuration. By default, succeeded jobs will go to the deleted state after 36 hours and they will then be permanently deleted after 72 hours.
Thanks to the
deleteOnFailure attributes on the
@Job annotation you know have fine-grained control per Job on when it will move from the
Succeeded state to the
Deleted state and when the
Job will be deleted permanently.
Specifying a custom delete policy for a job is easy thanks to the
Job annotation. Just add it to your service method and specify when you want your job to be deleted.
deleteOnFailure attribute accept the following string format:
duration1(optional): the duration in ISO8601 format before the job will move from
!(optional): a separator
duration2(optional): the duration in ISO8601 format before the job will be permanently deleted
Below is a table with some examples:
||After 10 minutes||After default configured in
||After 10 minutes||After 2 hours|
||After 2 days and 10 minutes||Immediately (won’t be available in
||Immediately||After 2 hours|
As you can specify both
deleteOnFailure, this means you can keep failed jobs around longer (to see what went wrong). If you don’t specify
deleteOnFailure, it falls back to JobRunr’s default which means the job will stay in the
Failed state until manual action is taken.