HttpContext Session null in new Job (Quartz.Net)

1.3k Views Asked by At

I want to put together a scheduler for web data processing to limit the number of jobs, so I used the Quartz.Net framework and put that on top of IHttpAsyncHandler.

public void ProcessRequest(HttpContext context)
{
    // StdSchedulerFactory.GetDefaultScheduler().Start(); etc           
    Global.scheduler.start();

    // IJobDetail job = JobBuilder.Create<T>().WithIdentity(jobId, "Processing").Build(); etc
    Global.scheduler.AddProcessingJob<JobRxFormulas>(user, app, arguments);
}

I have passed the HttpContext into job via arguments, which works fine, but when I want to grab context.Session it is null - which makes sense as I added the processing job into it's own queue and the HttpAsyncHandler process has finished. I haven't tried, but I assume returning the result will also fail for the same reason:

context.Response.Write(json);

One idea I have is that I could declare a lock and add this loop to ProcessRequest:

while (lock);

But not sure this is the best idea.

How do I best keep the HttpContext for the handler alive so I can return the result? Or can I even return the result from the Quartz job back to ProcessRequest (like a promise in Javascript, ie $.when.then) and then send it back via context.Response?

Or would it be better to scrap Quartz completely and let HttpAsyncHandler do the job scheduling in the first place?

https://stackoverflow.com/questions/33642861/processing-job-scheduling-with-httpasynchandler

0

There are 0 best solutions below