- Notifications
You must be signed in to change notification settings - Fork20
Small demo showing how to implement Pub/Sub with a BackgroundWorker in .NET Core
mizrael/WebApiWithBackgroundWorker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This repository contains a simple implementation of Pub/Sub in .NET Core. This code has been used as example accompaining a series of articles on my personal blog:https://www.davidguida.net/consuming-message-queues-using-net-core-background-workers-part-1-message-queues/
The Publisher is implemented a simple Console application. The user will be prompted to write a text message which will be sent to a RabbitMQ fanout exchange.
The Subscriber is implemented as a .NET Core Background Worker hosted in a Web API. The Worker is starting the subscriber and listening for incoming messages.
Messages are internally processed using a Producer/Consumer mechanism leveraging the System.Threading.Channels library.
Once a message is received, the worker will send it to a Producer which will then dispatch on a Channel. A certain number of Consumers has been registered at bootstrap. The first available Consumer will pick up the message and store it in a repository.
The Web API exposes a single GET endpoint /messages which will return the list of received messages.
For more details about Producer/Consumer, check this article:https://www.davidguida.net/how-to-implement-producer-consumer-with-system-threading-channels/
About
Small demo showing how to implement Pub/Sub with a BackgroundWorker in .NET Core
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.