4

I have been using queues and PubSub patterns for years but never really came across the terminology "event bus". After some googling I didn't really find a clear distinction between "event bus" and "PubSub". Are they the same, just semantic differences?

In the AWS world PubSub seems to imply SNS and event bus seem to imply EventBridge. This makes me think there is a difference.

The difference between SNS and EventBridge is fairly clear. SNS seem to be more towards "fire and forget" while EventBridge has more routing capabilities. SNS also scales on a different level.

In short, what is an event bus? What is event bus vs PubSub?

I came across this link

Frankster
  • 189

1 Answers1

7

For the "publisher/subscriber" pattern, subscriber components have to subscribe (or unsubscribe) to an event publisher. This means the life time of the event publishers is as least as long or longer than any of its subscribers. There are lots of simple scenarios where this is sufficient.

However, when you have a system where you have certain event publishers for a certain type of event, and you may also have subscribers for this type of event, and the life times of publishers and subscribers is completely independent from each other, you need a middle-man component to manage this. That middle-man is called an event-bus.

The event bus has a life time as long as your application or system runs. Subscribers subscribe to the certain type of event at that that bus, and publishers raise the events there.

So, an event bus fullfills a very similar purpose like an event queue, but it does not necessarily provide any FIFO guarantees. For the differences between the latter, I recommend this Stackoverflow question: Message Queue vs Message Bus -- what are the differences?.

Doc Brown
  • 218,378