Search code examples
hangfirehangfire-sqlhangfire-console

Hangfire and main app in different applications


We have web application developed in .NET Core and is hosted on azure. We want to use HangFire for report scheduling.

Our application is multitenant so it will have load of its own, So I want to run these background processes into different server. HangFire has option of Placing Processing into Another Process as Using Console applications or Using Windows Services.

I have gone through HangFire Doc but there is no clear explanation of how this main application (which is .NET CORE) connects to this Console application?

https://docs.hangfire.io/en/latest/background-processing/placing-processing-into-another-process.html

I came across this question but still is not clear to me

How to run Hangfire as a separate process from the main web application?


Solution

  • Your AspNet .Net Core application (the hangfire client) will not communicate directly with the console application (the hangfire server).

    Communication is done trhough the storage (the database) : client declares new tasks in the storage, and the server polls the storage (or is notified by the storage depending on the storage technology, like Redis) to execute the tasks.

    You need to ensure communication of both client and server with the storage, but not between the client and the server.