This is a working sample built on the ideas expressed in Calvin A. Allen's original blog post.
The sample shows a BackgroundService
listening for notifications from a PostgreSQL database instance. When a notification occurs, the application communicates through SignalR to all connected clients.
- .NET 5.0+
- PostgreSQL database instance
- Update the connection string in
appsettings.json
- Connect to your PostgreSQL database instance.
- Start the project using
dotnet run
. - Run the following
SQL
command from a database console window.
NOTIFY total_count, '1';
You should see the index page at https://localhost:5001
update with the value 1.
Try it with 9001
.
NOTIFY total_count, '9001';
Cheers!