Quartz XML plugin redirects triggers after reboot

I use the XML Planning Plugin ( XMLSchedulingDataProcessorPlugin ) to create multiple jobs and triggers when run in the JDBC job repository in . This works fine, but I have a problem with simple triggers configured to run only once.

When such a trigger fires, it is deleted from the database, since there is no next fire. So far, so good. Unfortunately, when I restart the application, the plugin cannot find this trigger to reinsert it again. Since I am using MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY , this task runs again and again from the database. Restarting the application repeats the entire process.

Obviously, I want my trigger to fire only once. Is it possible to save triggers triggered in the database, even if they do not have the next fire time? Or maybe it can be solved differently? Excerpt from my quartz_data.xml file:

 <processing-directives> <overwrite-existing-data>false</overwrite-existing-data> <ignore-duplicates>true</ignore-duplicates> </processing-directives> <schedule> <trigger> <simple> <!-- ... --> <start-time>2012-05-10T07:00:00Z</start-time> <repeat-count>0</repeat-count> <repeat-interval>0</repeat-interval> </simple> </trigger> 

Note that there is a problem with all triggers that have reached the last execution and therefore have been removed from db.

+1
source share
1 answer

I ended up extending the StdJDBCDelegate extension and overriding deleteTrigger() as no-op:

 package com.example; class DurableTriggersDriverDelegate extends StdJDBCDelegate { public DurableTriggersDriverDelegate(Logger logger, String tablePrefix, String schedName, String instanceId, ClassLoadHelper classLoadHelper) { super(logger, tablePrefix, schedName, instanceId, classLoadHelper); } public DurableTriggersDriverDelegate(Logger logger, String tablePrefix, String schedName, String instanceId, ClassLoadHelper classLoadHelper, Boolean useProperties) { super(logger, tablePrefix, schedName, instanceId, classLoadHelper, useProperties); } @Override public int deleteTrigger(Connection conn, TriggerKey triggerKey) throws SQLException { this.logger.debug("deleteTrigger(" + conn + ") skipped"); return 1; } } 

The new implementation can be easily connected via quartz.properties :

 org.quartz.jobStore.driverDelegateClass=com.example.DurableTriggersDriverDelegate 

This solution has several disadvantages:

  • the database continues to grow and grow without deleting triggers

  • deleting a task is impossible, since it first tries to delete all the triggers (but this does not happen), and a violation of the restriction occurs when you try to delete the data about the work

However, he solved my original problem.

0
source

Source: https://habr.com/ru/post/1413541/


All Articles