A Python library offering a unified API over AMQP and other transports for producers, consumers, exchanges, and queues.
Overview
Kombu provides idiomatic messaging primitives for Python programs that need to publish and consume events across brokers. It focuses on AMQP semantics—exchanges, queues, routing keys, and reliability—while letting applications swap underlying transports through plugins.
Built-in transports include native AMQP via py-amqp or qpid-python plus virtual transports for Redis, Amazon SQS, MongoDB, ZooKeeper, in-memory testing, and several other backends documented in a comparison table. The library handles serialization, compression, consistent exceptions across transports, and graceful recovery from connection or channel errors.
Typical code constructs Connection, Exchange, and Queue objects, publishes JSON payloads with routing metadata, and consumes with callbacks that acknowledge messages. Connection pools, automatic failover, and carrot compatibility layers are part of the documented feature set.
Kombu underpins the Celery task queue ecosystem and installs from PyPI with standard packaging tools. Terminology sections in the docs explain producers, consumers, exchanges, queues, and routing types such as direct, fanout, and topic matching.
Key features
- Pluggable message transports
- AMQP exchanges, queues, and routing
- Redis, SQS, and MongoDB transports
- Automatic serialization and compression
- Consistent errors across backends
- Connection and producer pools
- In-memory transport for tests
- Carrot compatibility layer
Use cases
- Backend messaging for Celery workers
- Multi-broker Python integrations
- RPC-style task queues
- Testing messaging without a broker
- Routing events with topic patterns