lapin
An async AMQP 0-9-1 client library for Rust, targeting RabbitMQ
Repository Health
Technical Analysis
lapin is a pure-Rust, async client library implementing the AMQP 0-9-1 protocol, the messaging protocol spoken by RabbitMQ and compatible brokers. It lets Rust services publish and consume messages, declare exchanges and queues, and manage channels over a fully asynchronous I/O layer, with an ergonomic API modeled directly on AMQP concepts.
lapin is runtime-agnostic — the same code runs on tokio (the default), smol, or async-global-executor — and ships production features such as automatic connection recovery, publisher confirms, and multiple selectable TLS backends. It builds on the amq-protocol codec crate and is one of the most widely used RabbitMQ clients in the Rust ecosystem.
What You Get
- An async Connection/Channel API for publishing and consuming AMQP messages
- Full AMQP 0-9-1 operations: declare exchanges/queues, bind, publish, consume, and acknowledge
- Runtime-agnostic design working with tokio, smol, or async-global-executor
- Automatic connection recovery and publisher-confirm support for reliable delivery
- Selectable TLS backends (rustls, native-tls, or OpenSSL) via Cargo features
Common Use Cases
- Publishing and consuming RabbitMQ messages from async Rust services
- Building work-queue and background-job pipelines backed by AMQP
- Implementing pub/sub and topic routing between microservices
- Adding reliable, confirmed message delivery with automatic reconnection
Under The Hood
Architecture — lapin models the AMQP object graph directly: connection.rs and connection_builder.rs establish and configure the transport, channels.rs/channel.rs multiplex logical channels over one connection, and consumer.rs, queue.rs, exchange.rs, and publisher_confirm.rs implement the protocol operations. A central io_loop.rs drives the async socket, frames.rs/parsing.rs handle AMQP framing, and a family of *_status.rs and channel_recovery_context.rs/topology.rs modules track state and rebuild it during automatic recovery. Generated protocol code lives under src/generated, produced from amq-protocol via build.rs.
Tech Stack — Rust 2024 edition (MSRV 1.88), built on async primitives (futures-core/io, async-trait, event-listener) and layered over the amq-protocol crate for the AMQP codec. It is runtime-agnostic through Cargo features that wire in tokio, smol, or async-global-executor, and offers rustls, native-tls, or OpenSSL for transport security with several crypto-provider and certificate options.
Code Quality — The codebase is large but sharply decomposed into single-responsibility modules, with a clippy.toml for lint configuration and a tests/ suite covering connections, publisher confirms, runtime isolation, and both tokio and smol runtimes. Coverage is tracked via Coveralls and CI runs build-and-test on every change; protocol code is regenerated rather than hand-edited to reduce drift.
API Design — The public API reads like the AMQP spec: Connection::connect, create_channel, queue_declare, basic_publish, and basic_consume with typed option structs. The README quick-start is a complete publish/consume program, and the examples/ directory demonstrates pub/sub, publisher confirms, TLS client certificates, and manual/semi-automatic reconnection. Familiarity with AMQP concepts (exchanges, bindings, acknowledgements) is the main learning cost.
Used by 3 apps in this directory
iii
Developer Tools · Devops
Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.
Laminar
AI Development · Monitoring
Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.
Svix
Developer Tools · Automation
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.