Skip to main content

Transports

Redis carries messages three ways: a stream keeps entries for consumer groups, a list hands each entry to one consumer, a channel keeps nothing.

A producer writes to a stream, a list and a channel, and each transport hands the message to its readers differentlyXADDLPUSHPUBLISHStreamkeeps every entryListuntil poppedChannelkeeps nothingGroupbillingGroupauditConsumerstake turnsClientAClientBJoins later:never sees itEach group readsevery entryEach entry goesto one consumer
The diagram as text
  1. XADD → Stream keeps every entry
  2. LPUSH → List until popped
  3. PUBLISH → Channel keeps nothing
  4. Stream keeps every entry → Group billing
  5. Stream keeps every entry → Group audit
  6. List until popped → Consumers take turns
  7. Channel keeps nothing → Client A
  8. Channel keeps nothing → Client B
  9. Joins later: never sees it
  10. Each group reads every entry
  11. Each entry goes to one consumer

A stream is an append-only log. XADD appends an entry under an id the server assigns, and the entry stays until the stream is trimmed. A consumer group reads the stream with a cursor of its own, so two groups each receive every entry. Inside one group, each entry goes to one consumer. Groups draws how a group tracks what it delivered.

A list is a queue. A producer pushes with LPUSH, a consumer pops from the other end, and a popped entry is gone from Redis. Queues draws how a reliable list keeps an entry until its handler settles it.

A channel stores nothing. PUBLISH pushes a message to the clients subscribed at that moment, and a client that subscribes later never sees it. Broadcast draws it.

A service reads each transport through its own descriptor: RedisStream, RedisList and RedisPubSub. The handler is the same #[subscriber] function on all three. What an acknowledgement means differs, as Settlement draws.