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

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?

you could call

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

for each of your connection strings in your application.

1 Like

Thank you. That seemed to do the trick.

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