2 (13.05.2023 6m) Flashcards

1
Q

Describe the IJob interface and its purpose.

A

The interface is used to define code that runs every job execution. When you want to create a job. You have to declare a class that implements the IJob interface.

IJob interface contains only one method, which is Execute.

public interface IJob
 {
     Task Execute(JobExecutionContext context);
 }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does JobExecutionContext contain?

A
  1. A handle to the Scheduler that executed job
  2. A handle to the Trigger that triggered the execution
  3. JobDetail object
  4. Merged JobDataMap
  5. Other items
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is IJobDetail? When is IJobDetail created?

A

IJob defines only code to execute when a job is fired.
But to create a schedulable Quartz.Net job you have to instantiate IJobDetail.
IJobDetail incapsulates IJob and contains information that describes for Quartz.Net how to treat jobs during scheduling and execution, along with identification and state (JobDataMap).

The IJobDetail object is created by the Quartz.NET client (your program) at the time the Job is added to the scheduler using JobBuilder.

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

What is JobDataMap for, talking about jobs? Why you don’t want just use class properties instead of JobDataMap? Give an example of setting JobDataMap during job building.

A

It can be used to store state information for a given instance of a job (IJobDetails).
JobDataMap presents in IJobDetails.

As IJob class instances are usually recreated, the JobDataMap is the best way to provide properties/configuration for an IJob class instance and keep track of a job’s state between executions.

Also you may want have different inputs to jobs for different IJobDetails.

Example:
IJobDetail job = JobBuilder.Create< HelloJob >()
.WithIdentity(“myJob”, “group1”) // name “myJob”, group “group1”
.UsingJobData(“jobSays”, “Hello World!”)
.UsingJobData(“myFloatValue”, 3.141f)
.Build();

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

What is JobDataMap for, talking about triggers?

A

Triggers may also have a JobDataMap associated with them.

This can be useful in the case where you have a Job that is stored in the scheduler for regular/repeated use by multiple Triggers, yet with each independent triggering, you want to supply the Job with different data inputs.

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