Between publishers and subscribers sits a broker or message bus. The publisher hands a message to the broker, the broker accepts it (durable brokers also persist it), and then the broker is responsible for getting a copy to each subscriber. Redis Pub/Sub, Google Cloud Pub/Sub, Apache Kafka, NATS, and AWS SNS all play this broker role with different guarantees.
Two filtering models are common. Topic-based filtering routes by a channel name, so a subscriber to orders.created gets every message on that channel. Content-based filtering lets subscribers specify a rule, for example only messages where amount is greater than 1000, and the broker evaluates the rule before delivering.
Delivery semantics matter a lot. Plain Redis Pub/Sub is fire-and-forget: if a subscriber is offline when a message is published, it never sees that message. Durable systems like Kafka and Google Cloud Pub/Sub keep messages on disk and track each subscriber's read position, so a subscriber that was down for an hour catches up when it returns. Most durable brokers offer at-least-once delivery, which means a consumer can occasionally receive the same message twice and must handle that idempotently.