4

I'm running a clustered instance of Quartz in the context of a Java EE application. One of the nodes (selected randomly) in the Java EE application will fire a series of Quartz jobs to be executed immediately (as explained in this post); right before triggering each job, a JobListener associated to that job is added to the scheduler's ListenerManager.

If I understand Quartz's inner working correctly, the node that actually executes each job will be selected at random from the available nodes. If that's the case, how can the listener's methods be called if the listener was created in a node different from the one that executed the job? Can I assume that the list of listeners in ListenerManager is global and the same for all the nodes in the cluster? Or each node has its own ListManager with its own listeners?

Community
  • 1
  • 1
Óscar López
  • 232,561
  • 37
  • 312
  • 386

2 Answers2

3

I found some more useful information in a free, online book:

Using Global Listeners in a Clustered Environment

You can still use job and trigger listeners in a clustered environment. The only confusion comes in when you try to understand which Scheduler instance will receive the callback method.

The easiest way to remember this is that the Listener will be notified in the Scheduler instance where the job or trigger is executed. Because a job and trigger are executed on only a single node, the Listener is notified on that node.

Carra
  • 17,808
  • 7
  • 62
  • 75
2

As per Quartz documentation:

Listeners are registered with the scheduler during run time, and are NOT stored in the JobStore along with the jobs and triggers. This is because listeners are typically an integration point with your application. Hence, each time your application runs, the listeners need to be re-registered with the scheduler.

Refer to http://quartz-scheduler.org/files/documentation/Quartz-2.1.x-Documentation.pdf

Hope this helps

TLama
  • 75,147
  • 17
  • 214
  • 392
SAM
  • 36
  • 4