I have an MVC web application that’s scheduling jobs, there’s a separate HangFire server process that will run those jobs. Jobs are being scheduled fine, however I can’t access the jobs programatically. I’m doing this;
JobData job = JobStorage.Current.GetConnection().GetJobData("THE_JOB_ID");
but the call returns null - why would that be? Is it because the current process is not a HangFire server?
What I want to find out is whether a job with a given Id actually exists.
Are you setting the storage connection anywhere in that process ? E.g: http://docs.hangfire.io/en/latest/configuration/using-sql-server.html
Yes, I am setting the configuration to use SQL Server at application startup.
In fact I am able to load job info, I’d just had the wrong expectation about what to expect from the function calls. I can get job data like this;
var jobs = JobStorage.Current.GetConnection().GetRecurringJobs().Where(j => j.Id == recurringJobId);
However, I was trying these calls which both return null in my case.
var job = JobStorage.Current.GetConnection().GetJobData(recurringJobId);
var state = JobStorage.Current.GetConnection().GetStateData(recurringJobId);