mooq

An asyncio compatible library for interacting with a RabbitMQ AMQP broker


Keywords
amqp, pika, rabbitmq, amqp0-9-1, asyncio, python, python-3-6
License
MIT
Install
pip install mooq==0.1.1

Documentation

docs/_static/logo_full2.png

http://tactile.com.au/jenkins/buildStatus/icon?job=mooq1 https://tactile.com.au/badge-server/coverage/mooq1

mooq is an asyncio compatible library for interacting with a RabbitMQ AMQP broker.

Features

  • Uses asyncio. No more callback hell.
  • Simplified and pythonic API to RabbitMQ
  • Built on top of the proven pika library
  • Comes with an in memory broker for unit testing projects that depend on RabbitMQ

Get It Now

$ pip install mooq

Just mooq it

Creating a connection:

conn = await mooq.connect(
            host="localhost",
            port=5672,
            broker="rabbit"
            )

Creating a channel of the connection:

chan = await conn.create_channel()

Registering a producer:

await chan.register_producer(
        exchange_name="log",
        exchange_type="direct")

Registering a consumer and associated callback:

async def yell_it(resp):
    print(resp['msg'].upper())

await chan.register_consumer(
        exchange_name="log",
        exchange_type="direct",
        routing_keys=["greetings","goodbyes"],
        callback = yell_it)

Publishing a message:

await chan.publish(exchange_name="log",
                   msg="Hello World!",
                   routing_key="greetings")

Process messages asynchronously, running associated callbacks:

loop = asyncio.get_event_loop()
loop.create_task(conn.process_events())

More at https://mooq.readthedocs.io

Project Links

License

MIT licensed. See the bundled LICENSE file for more details.