Quartz scheduler: Vetoing job execution causes trigger to never fire again - quartz-scheduler

I am working with a quartz implementation in a Java web app. We have implemented the TriggerListener class so when a trigger fires, it calls the vetoJobExecution(Trigger trigger, JobExecutionContext jobExecutionContext) method. We check a reference table to see if the job should run or not. All of this works fine.
The part that is broken is if the job should NOT run, so the vetoJobExecution method returns false. After that happens, the trigger will never fire again. This is the part I do not understand. It seems like the trigger should continue firing, and the vetoJobExecution method should keep being called to see if the job should run. This simply doesn't happen - once the job is vetoed, the trigger does not fire again and the vetoJobExecution method is never called.
We are using Quartz 1.5.2 (yeah it's old, I know).
What is the correct strategy for having a quartz job not run using the TriggerListener interface, yet still having the trigger fire next time?

Fixed by upgrading to version 1.7.3.

Related

Is there a mechanism to signal the workflow immediately about the failure/time-out of an asynchronous activity

We want to implement a use-case using cadence-workflow where we want to trigger a long-running asynchronous activity and then proceed with the execution of other activities. If in the meantime, for some reason that long-running activity is failed/timed-out, we would like to stop execution of the workflow and trigger compensation activities.
When an activity is invoked asynchronously it returns its result as Future (in Go SDK) or Promise (in Java SDK). Then the rest of the workflow can proceed without waiting on the result. The result can be used to cancel the other part of the workflow code when the activity fails or times out. When cancelled the code can execute whatever cleanup logic necessary. The concrete implementation depends on which SDK you are using.

Listener which notifies when job initialization is done with QUARTZ 2.2.x

I have implemented quartz 2.2.0 for the scheduling job in my project.
Now i want to check some conditions before job starts.
So is there any listener method that can notify me when job initialized or when it is going to run for the first time.
Thanks in advance.

Waiting for a Future to complete before making assertions

I have a Scala Play application and one of the controllers fires a Future which does some logging. I have a simple call back function which executes when the Future completes.
I have written a test to check whether this logging happens. The rough logic is as follows:
feature{
scenario{
Given()
// set up the call
When()
// make a FakeRequest via reverse routing - logging will done in a separate thread via a Future
Then()
Thread.sleep(50) // sleep to allow logging to finish
// check if the logging has been done
The issue is the Thread.sleep. I have added that call in to block the main testing thread in order to give enough time to elapse for the Future which does the logging in a separate thread to complete before actually doing the checks to see if the logging has been done.
My question is whether there is a better way to do this? In reality if my application is running and the logging is taking an inordinate amount of time, then the main thread which governs the application will not terminate until the Future that does the logging in a separate thread finishes. So I don't see a problem of putting in the Thread call above to simulate that. But I just want to confirm if this is correct.
For me, there is absolutely no other way than to do this. If I try to replicate how the app behaves in reality with my test, then the main thread for the test should complete and terminate even though the future for the logging is still going on; there is no call back in the test and neither should there be.
Assuming you're using ScalaTest ; you can use whenReady construct ; which periodically inspects the passed future, until it is either ready or the configured timeout has been surpassed;
see
http://www.artima.com/docs-scalatest-2.0.M5/org/scalatest/concurrent/Futures.html
http://doc.scalatest.org/2.0/index.html#org.scalatest.concurrent.ScalaFutures

Is Application.onFirstStart event fired on application upgrade?

Is Application.onFirstStart event fired on application upgrade? If not, is there any way to do something only once on upgrade or on the first start after upgarde?
onFirstStart will not run on update.
You can use onStart function, inside this function you can control application.version in order to understand if application is upgraded or not.

What is the difference between scheduleFinally and scheduleDeferred in GWT Scheduler?

I could not find my answer in this thread:
Using the GWT Scheduler
The GWT Scheduler class has scheduleDeferred API which executes after the browser event loop returns. The scheduleFinally API allows me to execute code before the control returns to the browser event loop.
How do I decide whether I should use scheduleDeferred or scheduleFinally? Is there a code example which shows the difference in behavior?
To understand this, you need to first get the basic idea of an event loop. When you write code to run in the browser, you don't write this loop - it lives in the browser, waiting for the user to do something. When that something happens (mouse event, keyboard event, AJAX call returns, setTimeout goes off), the loop calls into your code, and lets you handle it however you would like to.
So first, we have scheduleDeferred, which is a way to notify the browser that we have some code to run soon, but not in this loop. This is a handy way to let the browser regain control, render some content, and then give you control again. This can be helpful to break up calculations into several chunks to avoid any "long running script" errors, or can be an early attempt at animation (Note: use the actual requestAnimationFrame api from the browser, or AnimationScheduler.get().requestAnimationFrame in GWT instead for this).
Next, there are two interesting places in the loop where you might have code that you would like to run - either right as the browser transfers control to you, or right before you return control back again. Of these two, the end is usually more interesting: scheduleFinally. This lets you run some code inside the current event loop, but not until the very end of it. CssResource uses this strategy in its ensureInjected() method - when you run several different calls to this method, rather than poking the DOM several times, it batches them all up and runs them at the end of the event loop, using scheduleFinally.
The last one, the beginning of each event loop is managed by another method - scheduleEntry. In theory, this could be used in conjunction with finally to reimplement a simple version of AngularJS's binding wiring.
//event comes in to GWT from the $entry method, and follows these steps
try {
// 1. run registered scheduleEntry calls
// 2. run the current event or callback that the browser called us for
} finally {
// 3. run registered scheduleFinally calls
}
Any call to scheduleDeferred during those steps has added a call to the next event loop, to run as part of #2.