This library is meant to be used with RabbitMQ 4.x.
Version 1.0 will be deprecated in the November 2026. Please follow the version 2.0 Consider upgrading the library to version 2.0. Check the 2.x releases
The client is distributed via PIP:
pip install rabbitmq-amqp-python-clientInside the examples folder you can find a set of examples that show how to use the client.
Client Guide select the python section.
make rabbitmq-server: run the RabbitMQ server in a docker containerpoetry build: build the source projectpoetry install: resolves and install dependenciesmake test: run the tests
To run TLS you need to:
- pip uninstall python-qpid-proton
- brew install swig
- brew install pkg-config
- export CFLAGS="-I/usr/local/opt/openssl/include"; pip install python-qpid-proton --verbose --no-cache-dirRead more about the issue here
If when running tests, this exceptions is raised by the proton library: SSLUnavailable:
pip uninstall python-qpid-proton -y
sudo apt-get update
sudo apt-get install -y swig cmake build-essential libssl-dev pkg-config
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
export CFLAGS="-I/usr/include/openssl"
export LDFLAGS="-L/usr/lib/x86_64-linux-gnu"
pip install "python-qpid-proton>=0.39.0,<0.40.0" --no-binary python-qpid-proton --verbose --no-cache-dirThe client provides an async interface via the rabbitmq_amqp_python_client.asyncio module. The async classes act as facades that:
- Wrap the corresponding synchronous classes
- Execute blocking operations in a thread pool executor using
run_in_executor - Coordinate concurrent access using
asyncio.Lock - Implement proper async context managers (
async with) for resource management - Maintain API compatibility with the synchronous version
Key differences from the synchronous interface:
- Use
AsyncEnvironmentinstead ofEnvironment - All operations must be awaited with
await - Use
async withfor resource management (connections, publishers, consumers, management) - Consumer signal handling uses
asyncio.Eventandloop.add_signal_handler
For a complete example showing proper consumer termination and signal handling, refer to:
Additional async examples are available in the examples folder:
- OAuth2: examples/oauth/oAuth2_async.py
- Reconnection: examples/reconnection/reconnection_example_async.py
- Streams: examples/streams/example_with_streams_async.py
- TLS: examples/tls/tls_example_async.py
The TCP connection is not thread safe. If you want to use the client in a multithreaded environment, you should create a connection per thread.