7 (30.11.2022 3m) Flashcards

1
Q

Tell about job listener. Describe IJobListener interface.

A

Job listeners allow you to track events that happen with jobs.

Job-related events include a notification that the job is about to be executed and a notification when the job has completed execution.

public interface IJobListener
{
string Name { get; }

Task JobToBeExecuted(IJobExecutionContext context);

Task JobExecutionVetoed(IJobExecutionContext context);
	Task JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to add job or trigger listeners?

A

You can add/remove job or trigger listeners using scheduler.ListenerManager.

You can filter Jobs and Triggers by identity (e.g. groups or names) when you are interested in events from not all jobs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe exception handling danger related to trigger and job listeners.

A

Make sure your trigger and job listeners never throw an exception (use a try-catch) and that they can handle internal problems. Jobs can get stuck after Quartz is unable to determine whether the required logic in the listener was completed successfully when the listener notification failed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Tell about scheduler listener. Describe ISchedulerListener interface. Tell about exception handling.

A

SchedulerListener is much like ITriggerListener and IJobListener, except they receive notification of events within the scheduler itself - not necessarily events related to a specific trigger or job.

Scheduler-related events include: the addition of a job/trigger, the removal of a job/trigger, a serious error within the scheduler, notification of the scheduler being shutdown, and others.

public interface ISchedulerListener
{
	Task JobScheduled(Trigger trigger);
Task JobUnscheduled(string triggerName, string triggerGroup);

Task TriggerFinalized(Trigger trigger);

Task TriggersPaused(string triggerName, string triggerGroup);

Task TriggersResumed(string triggerName, string triggerGroup);

Task JobsPaused(string jobName, string jobGroup);

Task JobsResumed(string jobName, string jobGroup);

Task SchedulerError(string msg, SchedulerException cause);
	Task SchedulerShutdown();
} 

DANGER
Make sure your scheduler listeners never throw an exception (use a try-catch) and that they can handle internal problems. Quartz can get in unpredictable state when it is unable to determine whether required logic in listener was completed successfully when listener notification failed.

You can add/remove scheduler listeners using scheduler.ListenerManager.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is JobStore? Which JobStores do you know? Describe JobStore setup. Do you need to explicitly use JobStore?

A

JobStore is responsible for keeping track of all the “work data” that you give to the scheduler: jobs, triggers, calendars, etc.

You declare which JobStore your scheduler should use (and its configuration settings) in the properties file (or object) that you provide to the SchedulerFactory that you use to produce your scheduler instance. Or when using SchedulerBuilder you can use UsePersistentStore to use JobStoreTx, or omit this to use RAMJobStore

WARNING
Never use a JobStore instance directly in your code. The JobStore is for behind-the-scenes use of Quartz itself. You have to tell Quartz (through configuration) which JobStore to use, but then you should only work with the Scheduler interface in your code.

There are two IJobStore implementation so far: RAMJobStore, AdoJobStore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly