I’m working on a basic web client for Quartz.NET that among other things supports the modification of a job’s JobDataMap at runtime.
My job is decorated with the following attributes which I believe is all that is necessary to make the job stateful:
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class SampleTenantJob : IJob { ... }
At runtime, I execute the following code but the JobDataMap is not persisted:
public void UpdateJobProperties(string jobName, string groupName, IDictionary<string, object> properties)
{
IJobDetail job;
if (!TryGetJob(jobName, groupName, out job))
return;
foreach (var property in properties)
{
if (job.JobDataMap.ContainsKey(property.Key) && property.Value != null)
{
job.JobDataMap.Put(property.Key, property.Value);
}
}
}
I thought initially this was because I was using the XMLSchedulingDataProcessorPlugin for jobs but I’ve tried both the in memory (RAMStore) and AdoJobStore and still can not persist JobDataMap changes made by the remote client.
PersistJobDataAfterExecution (as the name implies) only applies when the job has finished executing, so the following job will track the number of times it is executed
Without the PersistJobDataAfterExecution attributes, count is always the same.
Since you aren’t running the job, this doesn’t help you, and I think you have to delete and re-create the job with the new JobDataMap.
Of course, you aren’t forced to use JobDataMap and can always to read and store information for your job from somewhere else.