Proper deregister and unschedule jobs on data center environment with multiple nodes

Hi Guys!

I have problem in my Jira Data Center plugin which implements dynamic scheduled Job. Implementation is very similar to this example:

The problem occurs on multiple nodes environment. After shut down one of nodes all scheduled job and job runner is missing from others nodes (which are still on). I have done some reserch and have conclustions that it might be becouse of deconstructing plugin on turning off node using DisposableBean → destroy() function.

Destroy() function is called before stop of the plugin thus is the good place to unschedule all jobs. However it seems that turning off one node runs this method for particular node, what unschedule all jobs and unregister Job Runner form all Cluster.

For the moment i’m not sure if i’m mising something or it’s correct behaviour and i have to implement it in some other way?

If so, i wolud like to implement some way to catch of stop/uninstall of my plugin to unschedule and deregister Job Runner correctly.

Cheers,
Jacek

You should only unschedule local jobs that run on every node, since these aren’t stored in the database.
For jobs that only run once per cluster you should only unregister the job runnter. If you unschedule these, as you’ve noticed, they are removed from the database and will stop on every node.
If you’re app gets uninstalled it will leave the scheduled job, but since you unregistered the runner the job wont be executed anymore.

Hello T-bundt

All my scheduled jobs are run once per cluster so I tried just to deregister job runner without unscheduling them and it’s works.

However it would be cool to remove these jobs on deactivation/unlinstal of plugin. Is there any way to do it?

Hi Jacek,

I can’t think of a nice way to achieve this.