I am trying to enable HA on nodes and in that process I found that in a two test node setup a job that has a frequency of 10 sec was running into deadlock. So I tried upgrading from Quartz 1.8 to 2.1 by following the migration guide but I ran into an exception that says "Jobs added with no trigger must be durable.".
After looking into spring and Quartz code I figured out that now Quartz is more strict and earlier the scheduler.addJob had a replace parameter which if passed to true would skip the durable check, in latest quartz this is fixed but spring hasnt caught up to this. So what do you do, well I jsut inherited the factory and set durability to true and use that
public class DurableJobDetailFactoryBean extends JobDetailFactoryBean {
public DurableJobDetailFactoryBean() {
setDurability(true);
}
}
and used this instead of JobDetailFactoryBean in the spring bean definition
<bean id="restoreJob" class="com.xxx.infrastructure.quartz.DurableJobDetailFactoryBean">
After looking into spring and Quartz code I figured out that now Quartz is more strict and earlier the scheduler.addJob had a replace parameter which if passed to true would skip the durable check, in latest quartz this is fixed but spring hasnt caught up to this. So what do you do, well I jsut inherited the factory and set durability to true and use that
public class DurableJobDetailFactoryBean extends JobDetailFactoryBean {
public DurableJobDetailFactoryBean() {
setDurability(true);
}
}
and used this instead of JobDetailFactoryBean in the spring bean definition
<bean id="restoreJob" class="com.xxx.infrastructure.quartz.DurableJobDetailFactoryBean">
You don't need to do that ... You can set durability with a property:
ReplyDeleteYou only have to set durability property to true while defining your job bean:
ReplyDeleteI know but what if a programmer forgets to define durability. I wanted to take care of that because I knew all my jobs need to be durable.
DeleteI need to modify all my job definitions to be durable just because Spring didn't catch up with Quartz? It's a workaround, but doesn't sound right. The DurableJobDetailFactoryBean approach is also a workaround. I'll discuss in spring forum and probably open a jira request
ReplyDeleteThanks
ReplyDeleteSpring 4 now has this in JobDetailFactoryBean.
ReplyDelete
ReplyDelete=)