Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A simple event bus for .NET [closed]

Tags:

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.

like image 494
chikak Avatar asked Dec 15 '08 12:12

chikak


People also ask

What is event bus in C#?

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.

Is RabbitMQ an event bus?

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.

What is an event bus?

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.


1 Answers

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 
like image 188
Sean Kearon Avatar answered Sep 28 '22 12:09

Sean Kearon