ruststream-amqp implements the RustStream broker contract over fe2o3-amqp. Handlers, routers, codecs, and middleware come from the framework; this crate supplies the transport - and nothing broker-specific leaks back into the framework.
AMQP 1.0 is an ISO-standard protocol spoken by ActiveMQ Artemis and Classic, RabbitMQ 4.x (a separate protocol stack from the 0.9.1 that ruststream-lapin speaks), Azure Service Bus and Event Hubs, Amazon MQ, Solace, Apache Qpid, and IBM MQ - one crate serves the whole family.
Features
- Lazy startup contract.
AmqpBroker::new(url)is synchronous and does no I/O; the runtime connects once at startup, so the broker composes with#[ruststream::app]. SASL (ANONYMOUS, PLAIN, EXTERNAL) and the container id are builder options. - Acknowledgement as dispositions.
ackmaps toaccept,nack(requeue = true)torelease,nack(requeue = false)toreject- the broker's own dead-letter policy applies. At-most-once subscriptions reportAckError::Unsupportedinstead of pretending. - Explicit addressing. The protocol standardises the wire, not the meaning of an address:
AmqpAddress::queue(anycast),AmqpAddress::topic(multicast),AmqpAddress::raw(verbatim, for deployments with their own convention), pluscredit(prefetch as protocol-level flow control) and thesettleguarantee. - Native request/reply.
AmqpPublisherimplements theRequestReplycapability overreply-to,correlation-id, and a dynamic receiver link. - Transactions (feature
transaction). A distinctAmqpTransactionalPublishpolicy pairs into aTransactionalPublisherbuilt on the protocol's transactional posting; the plain publisher carries no transactional surface. - Headers without an envelope. Well-known headers ride the
propertiessection (content-type,correlation-id,reply-to,message-id, the partition key asgroup-id); everything else ridesapplication-properties, so non-Rust peers see plain AMQP messages. - In-process test broker (feature
testing).AmqpTestBrokerreproduces core routing with no server, implementsruststream::testing::TestableBroker, and passes the framework's conformance suite in process.
Status
Implemented and verified against ActiveMQ Artemis (the framework's conformance lifecycle, request/reply, and transactions suites run in CI against a live broker). Built on ruststream 0.6 from crates.io; the crate itself is not published yet. Design and scope are tracked in powersemmi/ruststream#187.
Write a service
use ;
use subscriber;
use ;
use Deserialize;
async
The descriptor carries the AMQP-specific options inline in the decorator:
async
Request/reply
The requester side is a first publish, so it belongs in the scope's after_startup hook: the
publisher arrives live, already paired with the connected broker.
use io;
use Duration;
use ;
use ;
use ;
The responder answers on the requester's dynamic reply-to address, so it publishes through an
injected publisher rather than the fixed-destination publish(..) reply form; see
examples/amqp_request_reply.rs for both sides in one app.
Test it
The testing feature runs handlers against an in-process AMQP stand-in - no server, same routing. Broker-specific behaviour (dispositions, credit, dead-lettering) is covered by the env-gated live suite instead: just test-brokers spins up ActiveMQ Artemis and runs the integration tests plus the framework conformance suites against it.
Layout
ruststream-amqp/
├── crates/
│ └── ruststream-amqp/ the published crate
│ └── examples/ runnable amqp_* examples
├── docker-compose.test.yml ActiveMQ Artemis for the live suite
└── Cargo.toml workspace
Contributing
License
Licensed under the Apache-2.0 license.