CFFI bindings to librabbitmq 0.8.0
Project description
rabbitmq
========
Python bindings to librabbitmq using CFFI
This is fairly rudimentary so far but does allow using librabbitmq on Python 3 to a basic degree, which was my primary motivation for this work.
Currently tested against librabbitmq 0.8.0 on Python 3.6 and 2.7. It is in production on Python 3.6 on two fairly heavily-loaded message queues.
Available [on PyPI](https://pypi.python.org/pypi/rabbitmq), just `pip install rabbitmq`.
Proper documentation coming soon. Example usage:
```python
import rabbitmq
conn = rabbitmq.Connection()
conn.open(AMQP_BROKER_HOST, AMQP_BROKER_PORT)
conn.login(AMQP_BROKER_VHOST, 0, AMQP_BROKER_USER, AMQP_BROKER_PASSWORD)
conn.open_channel(1)
conn.declare_exchange(1, "queuename", "direct")
conn.declare_queue(1, "queuename")
conn.bind_queue(1, "queuename", "queuename", "queuename")
conn.consume(1, "queuename")
publish_conn = rabbitmq.Connection()
publish_conn.open(AMQP_BROKER_HOST, AMQP_BROKER_PORT)
publish_conn.login(AMQP_BROKER_VHOST, 0, AMQP_BROKER_USER, AMQP_BROKER_PASSWORD)
publish_conn.open_channel(1)
publish_conn.declare_exchange(1, "exchangename", "direct")
while True:
envelope = conn.consume_message()
conn.ack(1, envelope.delivery_tag)
props = rabbitmq.Properties(content_type="...", delivery_mode=1)
body = b"..."
if len(body) > 8192:
# example of compressing large message bodies
from bz2 import compress
body = compress(body)
props.content_encoding = "bzip2"
publish_conn.publish(1, "exchangename", envelope.message.properties.reply_to, body, props)
```
========
Python bindings to librabbitmq using CFFI
This is fairly rudimentary so far but does allow using librabbitmq on Python 3 to a basic degree, which was my primary motivation for this work.
Currently tested against librabbitmq 0.8.0 on Python 3.6 and 2.7. It is in production on Python 3.6 on two fairly heavily-loaded message queues.
Available [on PyPI](https://pypi.python.org/pypi/rabbitmq), just `pip install rabbitmq`.
Proper documentation coming soon. Example usage:
```python
import rabbitmq
conn = rabbitmq.Connection()
conn.open(AMQP_BROKER_HOST, AMQP_BROKER_PORT)
conn.login(AMQP_BROKER_VHOST, 0, AMQP_BROKER_USER, AMQP_BROKER_PASSWORD)
conn.open_channel(1)
conn.declare_exchange(1, "queuename", "direct")
conn.declare_queue(1, "queuename")
conn.bind_queue(1, "queuename", "queuename", "queuename")
conn.consume(1, "queuename")
publish_conn = rabbitmq.Connection()
publish_conn.open(AMQP_BROKER_HOST, AMQP_BROKER_PORT)
publish_conn.login(AMQP_BROKER_VHOST, 0, AMQP_BROKER_USER, AMQP_BROKER_PASSWORD)
publish_conn.open_channel(1)
publish_conn.declare_exchange(1, "exchangename", "direct")
while True:
envelope = conn.consume_message()
conn.ack(1, envelope.delivery_tag)
props = rabbitmq.Properties(content_type="...", delivery_mode=1)
body = b"..."
if len(body) > 8192:
# example of compressing large message bodies
from bz2 import compress
body = compress(body)
props.content_encoding = "bzip2"
publish_conn.publish(1, "exchangename", envelope.message.properties.reply_to, body, props)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file rabbitmq-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: rabbitmq-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74cfbc0f365019a8f318cd1ad9b1f85682768568fa3816740df37509a6dfbc2d |
|
MD5 | a3adaaacfebb786ae4143e9fa9ca8b5c |
|
BLAKE2b-256 | bc1d6b4397309786eaba2dee82285773c383d41ab4b3ffdb933d9af48de52025 |