Bsft.Outbox.Postgres 2.3.0

dotnet add package Bsft.Outbox.Postgres --version 2.3.0
                    
NuGet\Install-Package Bsft.Outbox.Postgres -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bsft.Outbox.Postgres" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsft.Outbox.Postgres" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Bsft.Outbox.Postgres" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bsft.Outbox.Postgres --version 2.3.0
                    
#r "nuget: Bsft.Outbox.Postgres, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bsft.Outbox.Postgres@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bsft.Outbox.Postgres&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Bsft.Outbox.Postgres&version=2.3.0
                    
Install as a Cake Tool

Bsft.Outbox.Postgres

The PostgreSQL wake-up for any Bsft.Outbox outbox. A writer announces new rows on a notification channel; a listening session hears it and the hosted drain worker of Bsft.Outbox drains at once, instead of waiting out its poll interval.

It is an optimisation and nothing more. The worker's poll interval stays the guarantee: a notification that is never sent, never received, or lost with the connection it was travelling on costs one poll interval and no row. The lease, the retry schedule and the dead-letter policy are untouched.

It works for any outbox table because it knows nothing about the table. Whoever writes the rows announces them, and this package only listens.

Install

dotnet add package Bsft.Outbox.Postgres

Requires Bsft.Outbox.Abstractions (pulled transitively) and Npgsql. The listener needs no schema of its own: LISTEN/NOTIFY is a server feature. This package only supplies the signal; the worker that consumes it, drains the outbox and awaits the signal is the hosted drain worker of Bsft.Outbox (AddBsftOutboxDrainWorker), which is what you register alongside.

Register

services.AddBsftOutboxDrainWorker<MyPayload>("my-outbox");
services.AddBsftOutboxPostgresWake("my-outbox", options =>
{
    options.NotificationChannel = "my_outbox";
    options.ConnectionString = connectionString;
});

The name is the outbox's name: the signal is registered as a keyed IOutboxWakeSignal under it, and the drain worker of the same name picks it up. The signal is also a hosted service, which keeps the listening session alive and reconnects after the connection dropped.

The writer is yours: a trigger on the outbox table, or pg_notify in the transaction that wrote the row.

CREATE FUNCTION my_outbox_notify() RETURNS trigger AS $$
BEGIN PERFORM pg_notify('my_outbox', ''); RETURN NULL; END $$ LANGUAGE plpgsql;
CREATE TRIGGER my_outbox_notify AFTER INSERT ON my_outbox
  FOR EACH STATEMENT EXECUTE FUNCTION my_outbox_notify();

A notification is delivered at commit, so a drain that runs on it sees the row.

Configure

Bound from Bsft:Outbox:Postgres:Instances:<name> when the registration is handed an IConfiguration.

Option Default Effect
BsftOutboxPostgresOptions.NotificationChannel none, required The channel the writer announces on. Lower-case letters, digits and underscores, starting with a letter, at most 63 characters: it is quoted into a LISTEN statement, which takes an identifier and not a parameter.
BsftOutboxPostgresOptions.ConnectionString none, required The connection the listener opens for itself, taken from the pool of the connection string it is given and held for the host's lifetime (one pool slot: use a different connection string or Pooling=false to keep it out of the request pool). It has to reach the primary.
BsftOutboxPostgresOptions.ReconnectDelay 00:00:05 How long the listener waits before it reconnects. Must be positive.

Every new session raises the signal once as soon as its subscription is in place, so rows written while nothing was listened (start-up, a reconnect) are drained without waiting for the next write.

Shared with Bsft.Messaging.EFCore.Postgres

IPostgresListenSession is the one listening session: it opens the connection, subscribes, calls back once after the subscription and again for every notification. PostgresListenLoop is the reconnecting loop around it, and PostgresNotificationChannel the validated channel name both take. The wake-up of Bsft.Messaging.EFCore.Postgres listens through the same three.

The channel is handed to the server as a value and quoted there (format('%I')), so the LISTEN statement is never built from the name. The grammar stays as a start-up check: lower-case letters, digits and underscores, starting with a letter, at most 63 characters, because that is what makes the listening and the pg_notify side name the same channel.

Documentation

Topic page: docs/outbox.md. Conventions: docs/package-conventions.md.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Bsft.Outbox.Postgres:

Package Downloads
Bsft.Messaging.EFCore.Postgres

BSFT Framework PostgreSQL LISTEN/NOTIFY wake-up for the Bsft.Messaging EF Core outbox: the dispatcher drains on commit instead of waiting for its next poll.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 55 11/27/2026