Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Possible enhancement to QuartzAdaptor #75

Open
chhil opened this issue May 24, 2018 · 3 comments
Open

Possible enhancement to QuartzAdaptor #75

chhil opened this issue May 24, 2018 · 3 comments

Comments

@chhil
Copy link
Contributor

chhil commented May 24, 2018

I propose implementing the TriggerListener for the QuartzAdaptor. In the methods we can log info like when the trigger will fire again on trigger fire

e.g.

@Override
    public void triggerFired(Trigger trigger, JobExecutionContext context) {

        LogEvent evt = getLog().createInfo();
        evt.addMessage(getName() + " Trigger Fired and it will fire again at " + trigger.getNextFireTime() + "  "
                + context.getJobDetail());
        Logger.log(evt);

    }

    @Override
    public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) {
        return false;
    }

    @Override
    public void triggerMisfired(Trigger trigger) {
        LogEvent evt = getLog().createInfo();
        evt.addMessage(getName() + " Trigger MIS-Fired and will fire again at " + trigger.getNextFireTime());
        Logger.log(evt);

    }

I also propose adding a a misfire instruction when the trigger is created. At times the trigger does not fire and we have no clue what happened. The above trigger listener will help with logging the misfire.
Based on the default config of "org.quartz.jobStore.misfireThreshold", "60000", if the trigger is not fired in one minutes time it will be treated as a misfire and the instruction withMisfireHandlingInstructionFireAndProceed it will fire the trigger.

This may not suit everyone but can be made configurable to select what to do on a misfire.
e.g.

                trigger = TriggerBuilder.newTrigger()
                                        .withIdentity(e.getAttributeValue("id"), getName())
                                        .withSchedule(CronScheduleBuilder.cronSchedule(e.getAttributeValue("when"))
                                                                         .withMisfireHandlingInstructionFireAndProceed())
                                        .build();
@ar
Copy link
Member

ar commented May 25, 2018

Sounds like a good idea @chhil - do you want to provide a PR if you have it running or you want us to take a stab at this implementation?

@chhil
Copy link
Contributor Author

chhil commented May 25, 2018

I will make a pull request (next week). Its something I did recently so its been locally tested by me. The problem I usually face is with the code formatting. My custom eclipse code formatters will end up making showing a lot more changes, I will try my best to comply with the existing format.

@chhil
Copy link
Contributor Author

chhil commented May 25, 2018

There is one more change that would be nice. Jpos has the QuartzJobSupport , I added a new one called QuartzStatefulJobSupport. They are identical, except the stateful one has class level annotations: @PersistJobDataAfterExecution
@DisallowConcurrentExecution

So if an existing job is running, a concurrent one wont be started. Helps to extend your job which runs often and dont want multiple jobs running together.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants