Has anyone tried this or have any extra insight on whether this would be possible? I have looked through the forums/google and there are discussions of people using Hangfire with WCF but not in this manner.
Some background on our setup and my idea. It is a fairly large B2B solution with multiple layers (projects) supporting the needs like Contracts/Business/DAL/etc. The WCF service itself is mostly a presentation and communication layer in our solution.
I had originally intended on running a separate web app within our solution for both the Hangfire Server and Dashboard together. The more I think about it though, the WCF service itself is hosted inside IIS, setup as Always Running, and behaves similar to ASP.NET or Web API from a hosting standpoint. The Hangfire Dashboard has requirements for things like OWIN that don’t play nicely with WCF, so I am still going to host a separate web app for the Dashboard.
It feels like the Hangfire Server could just as easily be run as part of the WCF service itself rather than having to host it separately in ASP or MVC. I believe the major issues that could come up with this setup are that jobs would be queued/scheduled and they would never actually run or the WCF service itself would just bomb entirely for some reason. In the case of the jobs not running, I would know that I need to setup something separate to process those jobs temporarily and either try and resolve the issue or just go back to hosting the Hangfire Server somewhere else.
We have some internal integration tests that self host WCF, run tests against the endpoints, and then tear it all down. Using this same pattern, I have created a proof of concept where I setup and start the Hangfire Server within the test, queue some various jobs, and then make sure they run. So far this has worked successfully and exactly as expected. I am going to spend more time testing out this idea and possibly setting up a real instance of our application and see what happens.