amqp091-go
The official Go client library for the AMQP 0-9-1 protocol, maintained by the RabbitMQ team.
Repository Health
Technical Analysis
amqp091-go is the official Go client for AMQP 0-9-1, maintained directly by the RabbitMQ core team as the successor to the widely used streadway/amqp library. It gives Go applications a synchronous, channel-based API for publishing and consuming messages, declaring exchanges and queues, and managing bindings against RabbitMQ or any AMQP 0-9-1 compliant broker.
Beyond the core protocol implementation, the library adds production-oriented features: automatic connection and topology recovery, publisher confirms, TLS support, and hooks for observing asynchronous broker events like acks, nacks, and flow-control signals. It targets the two most recent Go release series and is exercised against real RabbitMQ instances in CI, making it the default choice for Go services that need a battle-tested, actively maintained AMQP client.
What You Get
- Full AMQP 0-9-1 protocol coverage - connections, channels, exchanges, queues, bindings, and the basic/confirm/tx method classes
- Automatic connection and topology recovery - a Recovery config reconnects and replays exchange, queue, binding, and consumer declarations after a dropped connection
- Publisher confirms and asynchronous notifications - Notify* methods surface acks, nacks, returns, flow-control, and blocked-connection events
- TLS and pluggable SASL authentication - amqps:// connections plus PLAIN and EXTERNAL auth mechanisms, extensible for custom mechanisms
Common Use Cases
- Publishing events from a Go service into RabbitMQ exchanges for downstream consumers
- Building worker processes that consume from queues with manual or automatic acknowledgement
- Implementing request/reply RPC patterns over AMQP with correlation IDs and reply-to queues
- Running resilient long-lived consumers that survive network blips via automatic topology recovery
Under The Hood
Architecture The library is organized around three cooperating layers: a low-level frame reader/writer (read.go, write.go, spec091.go) that encodes and decodes the AMQP 0-9-1 wire format; a Connection type (connection.go) that owns the TCP/TLS socket, heartbeat, and a background demultiplexing goroutine that routes incoming frames to the right Channel by channel number; and a Channel type (channel.go) that exposes the synchronous, RPC-style public API (Publish, Consume, QueueDeclare, etc.) built on top of internal call/response plumbing. A separate recovery.go layer wraps Connection and Channel to transparently replay topology (exchanges, queues, bindings, consumers) after a dropped connection, using consumerConfig-style stored parameters. Broadcasting to multiple listeners (Notify* channels) goes through a shared notifyAll helper with a bounded timeout so a slow listener can never wedge the reader goroutine — a concrete resilience mechanism baked into the core, not bolted on.
Tech Stack Written in pure Go (module github.com/rabbitmq/amqp091-go, go.mod requires Go 1.20) with a single external dependency, go.uber.org/goleak, used only for leak detection in tests. It relies entirely on the standard library for networking and TLS (net, crypto/tls, crypto/x509, bufio) rather than any third-party framework, keeping the runtime dependency footprint at effectively zero. Build tooling is a Makefile plus shell/PowerShell scripts for generating the protocol spec and managing TLS certs for integration tests; CI runs via GitHub Actions with a matrix across supported Go versions and a CodeQL security-scanning workflow.
Code Quality
Testing is extensive: over 200 test functions across unit, integration (client_test.go, integration_test.go), and dedicated recovery test suites (recovery_test.go alone is substantial), gated behind an integration build tag so unit and live-broker tests can run separately. Error handling is explicit and idiomatic Go — errors are returned rather than swallowed, and connection/channel failures propagate through NotifyClose channels. The project enforces golangci-lint (.golangci.yml) with the modernize linter enabled and only a few rules disabled for justified cases (e.g. relaxed complexity limits on integration_test.go). Naming and package structure are consistent and idiomatic, and CHANGELOG.md is actively maintained alongside tagged releases.
API Design The public API deliberately mirrors AMQP protocol method names and parameters (Channel.QueueDeclare, Channel.ExchangeBind, etc.), trading some Go idiom for a one-to-one mapping developers can cross-reference against the AMQP 0-9-1 spec. Synchronous methods return errors immediately in RPC fashion, while asynchronous protocol events (acks, flow, returns) are exposed through opt-in Notify* channel subscriptions rather than callbacks, keeping the base API simple for the common publish/consume path while still surfacing lower-level broker behavior for applications that need it. Godoc comments are thorough throughout doc.go and the public types, and the _examples directory (client, producer, consumer, pubsub, recovery) gives runnable references for the main integration patterns.
Used by 5 apps in this directory
Convoy
Developer Tools · Devops
Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.
Cozy Stack
File Storage · Productivity
Self-hosted personal cloud platform that unifies your files, apps, and devices in one private space you fully control.
Hatchet
AI Development · Developer Tools · Automation
A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.
MinIO
File Storage
High-performance, S3-compatible object storage built for AI/ML and analytics workloads — run it anywhere from a laptop to a petabyte-scale cluster.
Tyk API Gateway
Developer Tools · Devops
Cloud-native, high-performance open-source API gateway for REST, GraphQL, gRPC, and TCP — built in Go since 2014 with no feature lockout.