Queues and streams, inside the database.
A message broker built into the server, like the key/value cache. It speaks Kafka, AMQP 0-9-1 (RabbitMQ) and MQTT 3.1.1 and 5.0, plus a faster native protocol, over one engine with its own on-disk format.
Built into every 1.1.0 server. Not built yet: publishing inside a SQL transaction, and reading a topic with SELECT.
One publish, routed to every topic that wants it
New in 1.1.0: a message broker inside the database. Producers on the native protocol, Kafka, AMQP or MQTT publish to an exchange; bindings route each message to topics; subscriptions read them as a stream, a work queue or plain pub/sub.
- 1Producers, any protocol
A native client, a Kafka producer, a RabbitMQ client and an MQTT device all publish to the same broker, inside the same server as the database.
- 2An exchange routes
A topic exchange matches the routing key orders.eu.paid against its bindings: orders.eu.* and orders.#.
- 3Appended, once per topic
One copy goes to each matched topic, deduplicated, as a batch in the on-disk format the native protocol sends unchanged.
- 4Made durable
Per topic: sync acks after an fdatasync shared by every batch since the last one; async after the page cache; memory never touches disk.
- 5Three ways to read
ordered: a consumer group, partitions shared out. shared: a work queue with acks and dead-lettering. broadcast: every reader sees everything.
- 6Acked, or retried
A nack or a timeout redelivers to another consumer; after max deliveries the message moves to a dead-letter topic.
One engine, four doors
- Native rdbmq/1: the on-disk format is the wire format, so a batch is checked, stamped and appended as sent
- Kafka (classic protocol): producers, consumer groups, idempotent producers, SASL
- AMQP 0-9-1: exchanges, queues, publisher confirms, dead-letter exchanges, TTL
- MQTT 3.1.1 and 5.0: QoS 0/1/2, retained messages, persistent sessions, shared subscriptions
- BROKER statements on the SQL ports reach the same engine
rasterizeddb_core --broker-port 9800 --kafka-port 9092 --amqp-port 5672 --mqtt-port 1883
Every pattern from three primitives
A topic is a set of append-only partitions. A subscription reads one topic in one of three modes, and an exchange routes a publish to topics. Every messaging pattern people ask for is a combination of those.
- ordered: a consumer group; partitions shared out, order kept within each
- shared: competing consumers with per-message acks, redelivery and dead-lettering
- broadcast: plain pub/sub, every reader sees everything
- Exchanges: direct, fanout, topic (with * and # wildcards) and headers
Durability chosen per topic
Logins use the database's own roles, and topics and exchanges need an administrator to create. TLS uses the PostgreSQL port's certificate.
- sync: acknowledged after an fdatasync that one flush shares across every connection
- async: acknowledged from the page cache, flushed every few milliseconds
- memory: a bounded in-memory ring that never touches disk
Replicated, permissioned, crash-tested
- Replication: topics, batches at their offsets and subscription state ride the same replication stream as the database; a partition is written on one node at a time
- Permissions per topic and per exchange on every protocol, shown by BROKER SHOW GRANTS
- Crash tests kill the server mid-produce and check every durable acknowledgement; power loss is modelled with the same harness the database uses
- rdb_studio's BROKER page: topics, subscriptions and their permissions