lapin

An async AMQP 0-9-1 client library for Rust, targeting RabbitMQ

Library
Cargo
v4.10.0
1,232stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity72
Maintenance36
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture86
Code Quality84
Innovation82
Learning Curve70

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search