Skip to content

PostgreSQL

Terminal window
dotnet add package Surefire.PostgreSql
builder.Services.AddSurefire(options =>
{
options.UsePostgreSql("Host=localhost;Database=myapp");
});

This registers both the job store and notification provider. Real-time notifications use PostgreSQL’s LISTEN/NOTIFY, so workers pick up new jobs immediately instead of waiting for the next poll.

With AutoMigrate enabled (the default), Surefire creates the required PostgreSQL tables automatically. The current provider uses the built-in surefire_* table names.

In some setups you may want separate connections for the store and notification provider. For example, if you use PgBouncer in transaction mode for the store but need a direct connection for LISTEN/NOTIFY:

options.UsePostgreSqlStore("Host=pgbouncer;Database=myapp");
options.UsePostgreSqlNotifications("Host=primary;Database=myapp");

The PostgreSQL provider supports all Surefire features.