Skip to main content

A minimalistic & pythonic AMQP library focused on supporting RabbitMQ

Project description

rabbitpy - rabbitmq simplified

A pure python, thread-safe, minimalistic and pythonic BSD Licensed AMQP/RabbitMQ library that supports Python 2.6+ and Python 3.2+. Previously named rmqid.

[![Build Status](https://travis-ci.org/gmr/rabbitpy.png?branch=master)](https://travis-ci.org/gmr/rabbitpy)

Version History

0.5.1 - Installer/setup fix 0.5.0 - Bugfix release including low level socket sending fix and connection timeouts.

Installation

rabbitpy may be installed via the Python package index with the tool of your choice. I prefer pip:

pip install rabbitpy

But there’s always easy_install:

easy_install rabbitpy

rmqid Compatibility

rabbitpy is API compatible with rmqid.

Documentation

https://rabbitpy.readthedocs.org

Requirements

Python3 Caveats

  • Message bodies must use the bytes data type while most other values are strings.

Examples

Simple Publisher

The simple publisher is ideal for sending one off messages:

>>> rabbitpy.publish('amqp://guest:guest@localhost:5672/%2f',
                     exchange='test',
                     routing_key='example',
                     body='This is my test message')

If you want to add properties:

>>> rabbitpy.publish('amqp://guest:guest@localhost:5672/%2f',
                     exchange='test',
                     routing_key='example',
                     body='This is my test message',
                     properties={'content_type': 'text/plain'})

And publisher confirms:

>>> rabbitpy.publish('amqp://guest:guest@localhost:5672/%2f',
                     exchange='test',
                     routing_key='example',
                     body='This is my test message',
                     properties={'content_type': 'text/plain'},
                     confirm=True)
True
>>>

Simple Getter

>>> m = rabbitpy.get('amqp://guest:guest@localhost:5672/%2f', 'test')
>>> m.json()
{u'foo': u'bar'}

Simple Consumer

>>> with rabbitpy.consume('amqp://guest:guest@localhost:5672/%2f', 'test') as c:
..    for message in c.next_message():
...         print message.properties['message_id']
...         print message.body
...         message.ack()
...
856dfdc7-5ee3-4fc1-9635-977bf0043a9f
{"foo": "bar"}

More complex examples are available at https://rabbitpy.readthedocs.org

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbitpy-0.5.1.tar.gz (24.3 kB view details)

Uploaded Source

File details

Details for the file rabbitpy-0.5.1.tar.gz.

File metadata

  • Download URL: rabbitpy-0.5.1.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rabbitpy-0.5.1.tar.gz
Algorithm Hash digest
SHA256 a53c2ea4fa0794b8512d745f0725068a8fcc7b70b0badc5623f90ad89a9687c4
MD5 872a43d151c26de919a3fca927daab8d
BLAKE2b-256 7cdc335fede6c270bc97e1311a11d8a33789dd8525029c638414a6b7998945bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page