Skip to main content

Brokers

Handlers, routers, codecs, and middleware are broker-agnostic. You can move a service to another broker by changing one line at with_broker.

The framework ships a full in-memory broker for queues that stay inside a single application. Brokers backed by an external service are separate crates you add as a dependency.

Each broker crate has its own documentation site, linked in the Docs column and from the Brokers menu.

BrokerCrateTransportDocs
Memoryruststream (feature memory)in-process queue, no external servicethis site
NATSruststream-natsCore NATS and JetStreampowersemmi.github.io/ruststream-nats
Redisruststream-fredRedis Streams (standalone, cluster, sentinel)powersemmi.github.io/ruststream-fred
RabbitMQruststream-lapinAMQP 0.9.1 (queues, exchanges, publisher confirms, direct reply-to)powersemmi.github.io/ruststream-lapin
Kafkaruststream-rdkafkaApache Kafka (consumer groups, tracked commits, transactions, exactly-once pipelines)powersemmi.github.io/ruststream-rdkafka
AMQP 1.0ruststream-amqpActiveMQ Artemis, RabbitMQ 4.x, Azure Service Bus, and the wider AMQP 1.0 family (request/reply, transactions)powersemmi.github.io/ruststream-amqp
Google Cloud Pub/Subruststream-gcp-pubsubPub/Sub over the official client (ordering keys, exactly-once acknowledgement, dead-letter policies)powersemmi.github.io/ruststream-gcp-pubsub
AWS SQS / SNSruststream-sqs-snsSQS queues with SNS fan-out (FIFO groups, visibility management, native deferred retry)powersemmi.github.io/ruststream-sqs-sns
Apache Pulsarruststream-pulsarPulsar topics and patterns (subscription modes, dead-letter policies, repositioning)powersemmi.github.io/ruststream-pulsar
MQTT 5ruststream-rumqttcMQTT v5 (QoS levels, shared groups, retained messages)powersemmi.github.io/ruststream-rumqttc
ZeroMQruststream-zeromqBrokerless PUSH/PULL, PUB/SUB, and DEALER/ROUTER request/reply over TCP and IPCpowersemmi.github.io/ruststream-zeromq
Stream files / stdioruststream-sea-filePersistent replayable stream files and shell pipelines; zero infrastructure, full repositioningpowersemmi.github.io/ruststream-sea-file
AWS Kinesisruststream-kinesisKinesis data streams (shard leasing, checkpointing, repositioning)powersemmi.github.io/ruststream-kinesis
SQL databasesruststream-sqlxTask queues in the service's own Postgres, MySQL/MariaDB and SQLite tables, and a transactional outbox over any broker; statements checked at startup or at compile timepowersemmi.github.io/ruststream-sqlx

To implement a broker for another transport, start at the Broker trait: its rustdoc holds the contract a broker crate implements and the conformance suites that check it.

Switching brokers​

Every broker is constructed synchronously. The runtime connects it when the application starts. The examples below differ only in the line that constructs the broker.

use ruststream::memory::MemoryBroker;
use ruststream::runtime::{AppInfo, RustStream};

#[ruststream::app]
fn app() -> RustStream {
RustStream::new(AppInfo::new("orders", "0.1.0"))
.with_broker(MemoryBroker::new(), |b| b.include_router(routes::orders()))
}

Each broker crate documents its own connection options. When a subscription needs broker-specific options (consumer groups, durable names), you can write that broker's descriptor in the #[subscriber(..)] attribute; see broker-specific descriptors.