Skip to content
Latchkey

What Is an Event Bus? The Shared Channel for Events

An event bus is a shared channel through which components publish events and subscribe to the ones they care about, without referencing each other directly.

An event bus is the connective tissue of an event-driven design. Components drop events onto the bus and listen for the events they need, decoupled from who produced them. The same idea appears in two scales: an in-process event bus inside a single app, and a distributed event bus spanning services.

The shared-channel idea

Instead of wiring components together directly, you wire them all to a bus. A publisher posts an event; subscribers registered for that event type are invoked. Adding or removing a listener does not touch the publisher.

In-process versus distributed

An in-process event bus is just an object inside one application that routes events between modules. A distributed event bus runs over a broker and routes events between services. The pattern is the same; the blast radius and failure modes differ.

What it is good for

  • Decoupling modules or services that should not call each other directly.
  • Adding cross-cutting reactions (audit, notifications) without edits to producers.
  • Keeping a clean seam you can later split across the network.
  • Broadcasting domain events to many interested handlers.

Testing an event bus

An in-process bus is easy to test: publish an event and assert the right handlers ran, all in one process and fast in CI. A distributed bus needs the broker present, so those tests are slower and live in the integration layer.

Watch the hidden coupling

A bus hides dependencies. A change to an event type can break a subscriber you forgot existed, with no compiler to catch it. Treat event shapes as contracts and let the pipeline verify subscribers against them.

Where it fits a CI estate

Distributed event-bus tests boot infrastructure per run; an in-process bus does not. Knowing which kind you have tells you whether warm runners (such as Latchkey) are doing heavy lifting on your test times.

Key takeaways

  • An event bus is a shared channel for publishing and subscribing to events.
  • It exists in-process inside one app and distributed across services over a broker.
  • Its hidden coupling makes event schemas contracts worth verifying in the pipeline.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →