asynqp

An AMQP library for asyncio

Latest version: 0.6 registry icon
Maintenance score
0
Safety score
0
Popularity score
16
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.6 0 0 0 0 0
0.5.1 0 0 0 0 0
0.4 0 0 0 0 0
0.3 0 0 0 0 0
0.2.1 0 0 0 0 0
0.2 0 0 0 0 0
0.1 0 0 0 0 0

Stability
Latest release:

0.6 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



asynqp

Build Status Documentation Status Coverage Status Requirements Status

asynqp is an AMQP (aka RabbitMQ) client library for Python 3.4's new asyncio module.

Check out the official documentation.

Example

import asyncio
import asynqp


@asyncio.coroutine
def hello_world():
    """
    Sends a 'hello world' message and then reads it from the queue.
    """
    # connect to the RabbitMQ broker
    connection = yield from asynqp.connect('localhost', 5672, username='guest', password='guest')

    # Open a communications channel
    channel = yield from connection.open_channel()

    # Create a queue and an exchange on the broker
    exchange = yield from channel.declare_exchange('test.exchange', 'direct')
    queue = yield from channel.declare_queue('test.queue')

    # Bind the queue to the exchange, so the queue will get messages published to the exchange
    yield from queue.bind(exchange, 'routing.key')

    # If you pass in a dict it will be automatically converted to JSON
    msg = asynqp.Message({'hello': 'world'})
    exchange.publish(msg, 'routing.key')

    # Synchronously get a message from the queue
    received_message = yield from queue.get()
    print(received_message.json())  # get JSON from incoming messages easily

    # Acknowledge a delivered message
    received_message.ack()

    yield from channel.close()
    yield from connection.close()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(hello_world())

Installation

asynqp is on the Cheese Shop, so you can install it using Pip:

pip install asynqp

If you want the latest development version, you can install it from source:

git clone https://github.com/benjamin-hodgson/asynqp.git
cd asynqp
python setup.py install