3 (30.11.2022 3m) Flashcards
Describe Job and Triggers Identity.
Jobs and Triggers are given identifying keys when they are registered with the scheduler. The keys of Jobs and Triggers allow them to be placed into ‘groups’ which can be useful for organizing your jobs and triggers into categories such as “reporting jobs” and “maintenance jobs”.
The keys can be accessed using the Key property, which is the object of JobKey or TriggerKey class (depends on Job or Trigger is “this”) containing Group and Name properties.
The complete key (or identifier) of a job or trigger is the compound of the name and group. If you provide no group, think about this like job goes to the ‘null’ group. And names should be unique in the ‘null’ group.
When IJob instance is created? And what are ramifications of that?
Each (and every) time the scheduler executes the job, it creates a new instance of the IJob class before calling its Execute(..) method.
One of the ramifications of this behavior is the fact that jobs must have a no-argument constructor. Another ramification is that it does not make sense to have data fields defined on the job class - as their values would not be preserved between job executions.
What is JobDataMap in common? Why JobDataMap must contain serializable values? What problem does serialization bring with itself? What is recommendation of using JobDataMap?
The JobDataMap can be used to hold any number of (serializable) objects which you wish to have made available to the job instance when it executes.
JobDataMap is an implementation of the IDictionary interface and has some added convenience methods for storing and retrieving data of primitive types.
The important thing is that JobDataMap must contain serializable objects because of the clusterization feature.
Unfortunately, serialization can lead to class versioning problems in the case of persistent storage. For example, if you have persisted serialized object of the first version of a class, and trying to deserialize it to the second version of the class you will have an exception. So, be careful when adding custom classes to JobDataMap (and even standard .net classes).
It’s recommended to use only primitives and strings in JobDataMap. Quartz.Net even has a special mode that allows only primitives and strings in AdoJobStore and JobDataMap.
Describe JobDataMap mapping feature.
If you add properties with a set accessor to your job class that correspond to the names of keys in the JobDataMap, then Quartz’s default JobFactory implementation will automatically call those setters when the job is instantiated, thus preventing the need to explicitly get the values out of the map within your execute method. Note this functionality is not maintained by default when using a custom JobFactory.
Notice that for mapping context.MergedJobDataMap is used.
Describe purpose of JobDataMap of JobExecutionContext.
The JobDataMap that is found on the JobExecutionContext (context.MergedJobDataMap) during Job execution is a merge of the JobDataMap found on the JobDetail and the one found on the Trigger.
Trigger values override any same-named Job values.