#450·apprise

Support for AMQ Protocol

Author: gabyCreated Sep 25, 2021Updated Feb 19, 2023
Labelsenhancement

:bulb: The Idea Add support for AMQ protocol, more information about the protocol available here.

AMQ is heavily used by systems integrated via ActiveMQ, RabbitMQ

The most recommended library is Pika, there's also aio-pika with Async Support.

Example publisher using aio-pika:

import asyncio
import aio_pika


async def main(loop):
    connection = await aio_pika.connect_robust(
        "amqp://guest:[email protected]/", loop=loop
    )

    routing_key = "test_queue"

    channel = await connection.channel()    # type: aio_pika.Channel

    await channel.default_exchange.publish(
        aio_pika.Message(
            body='Hello {}'.format(routing_key).encode()
        ),
        routing_key=routing_key
    )

    await connection.close()


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