How to start multiple Hangfire servers (1 web application, multiple databases)?

sql-server
Tags: #<Tag:0x00007f6e44ab97f8>

#1

I have a website and multiple databases are attached to this one website. I access each database via a parameter in the URL.

I want to start a hangfire server for each of these databases.

I can easily read all the connection strings from the web.config.

To start a Hangfire server, do I just call Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage for each connection string? Or, do I call app.UseHangfireServer() with some sort of options for each server to start?


Using Hangfire with 1 Web application and multiple databases
#2

you could call

app.UseHangfireServer(new SqlServerStorage("cnName"), new BackgroundJobServerOptions());

for each of your connection strings in your application.


#3

Thank you. That seemed to do the trick.


#4

do you able to replicate jobs entries on both database? @Squid2k1