Continuation with distributed processing

I have a webapp and I’m trying to use Hangfire to offload processing of large reports onto a second server. I’m planning to use some kind of MQ to avoid latency.

  1. User loads App1 report page, configures parameters, clicks “Run”.
  2. The parameters are serialized to JSON and passed to a method on a SignalR hub in App1.
  3. ReportHub.Queue(string params) calls BackgroundJob.Enqueue(r => r.Process(params)
  4. App2 on a different server picks up the IBackgroundReports job, instantiates class BackgroundReports:IBackgroundReports, calls Process(string)
  5. ???
  6. Event raised in App1, sends download path as SignalR message to client
  7. JS callback on SignalR client triggers download of file.
  8. Profit!

From the sourcecode I can’t see whether ContinueWith jobs are handled immediately within the same worker that completes the parent job, or if the parent job completion just triggers a state change Awaiting->Enqueued in the child which would allow it to be picked up by a worker in a different App.

Workarounds:

  1. App1 could use a SQL Service Broker table dependency to watch for updates in the [HangFire].[Job] table. I’m on a shared SQL Server farm, this could get political.
  2. A continuewith for the report job enqueues a Notification job that is only processed by App1. Woo, more jobs.
  3. A continuewith that MQs the job ID back to App1. I’m not yet using MQ directly.
  4. A new feature for Hangfire.SqlServer.Msmq to allow apps to subscribe to state changes.