I want to make a very simple event bus which will allow any client to subscribe to a particular type of event and when any publisher pushes an event on the bus using EventBus.PushEvent()
method only the clients that subscribed to that particular event type will get the event.
I am using C# and .NET 2.0.
The event bus. An event bus allows publish/subscribe-style communication between microservices without requiring the components to explicitly be aware of each other, as shown in Figure 6-19.
RabbitMQ is an implementation of an event bus that implements event-based communication between different microservices developed using ASP.NET Core. RabbitMQ is an implementation of an event bus that implements event-based communication between different microservices developed using ASP.NET Core.
An event bus is a pipeline that receives events. Rules associated with the event bus evaluate events as they arrive. Each rule checks whether an event matches the rule's criteria. You associate a rule with a specific event bus, so the rule only applies to events received by that event bus.
Tiny Messenger is a good choice, I've been using it in a live project for 2.5 years now. Some code examples from the Wiki (link below):
Publishing
messageHub.Publish(new MyMessage());
Subscribing
messageHub.Subscribe<MyMessage>((m) => { MessageBox.Show("Message Received!"); }); messageHub.Subscribe<MyMessageAgain>((m) => { MessageBox.Show("Message Received!"); }, (m) => m.Content == "Testing");
The code's on GitHub: https://github.com/grumpydev/TinyMessenger
The Wiki is here: https://github.com/grumpydev/TinyMessenger/wiki
It has a Nuget package also
Install-Package TinyMessenger
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With