I’ve got a largge Quartz database that uses binary serialization across the board. I want to migrate everything in the JB to JSON serialization, and I’m using the example here as a guide.
I spin up quarts and configure the persistent job store to use the custom serializer. It loads all my blob_triggers and re-serializes them back into the database using JSON just fine, but even through it triggers the jobs, it doesn’t re-persist the jobdata column in JSON format.
In order to get Quartz to re-write the JobData to the database in the QUARTZ_JOB_DETAILS table, I have to change something in context.JobDetaul.JobDataMap. Here’s what I’m doing:
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
[Serializable]
public class MigrationJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
var jobData = context.JobDetail.JobDataMap;
var now = DateTimeOffset.Now;
jobData["MigratedAt"] = now; // without this line, the data doesn't re-persist
Console.WriteLine("{0} migrated at at {1}", context.JobDetail.Key.Name, now);
}
}
Is there a way to tell quartz to always persist job data rather than only when something about the JobDetails changes?