Implement Redis pub/sub fanout to broadcast messages to multiple subscribers
domain: redis.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Open a subscriber connection and subscribe to a channel: `SUBSCRIBE notifications` — the connection enters subscribe mode and blocks waiting for messages.
From a separate publisher connection, broadcast a message: `PUBLISH notifications '{"event":"order_created","id":42}'` — all current subscribers on that channel receive the message.
Use pattern subscriptions for dynamic channel names: `PSUBSCRIBE notifications.*` matches `notifications.orders`, `notifications.users`, etc.
In application code (e.g., Node.js with `ioredis`), create a dedicated subscriber client (separate from the command client) and attach a `message` event handler to process incoming publishes.
Monitor active channels and subscriber counts: `PUBSUB CHANNELS *` and `PUBSUB NUMSUB notifications`.
Known gotchas
Redis pub/sub is fire-and-forget — messages published when no subscriber is connected are lost; if durability is required, use Redis Streams or a persistent broker instead.
A connection in subscribe mode cannot execute regular Redis commands; always use a separate client instance for publishing versus subscribing.
Pub/sub does not support message acknowledgment or consumer groups — all subscribers receive every message, and there is no replay of missed messages.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?