apprise
apprise copied to clipboard
Support for AMQ Protocol
: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()
We'll keep this in the queue :slightly_smiling_face: . For this request, i presume it would be similar to MQTT where a 3rd party library becomes a dependant?
Currently all of the Apprise plugins work with all versions of Python (back to v2.7). This implementation would be restricted to v3.4+
(as per limitations of dependant third party). IT would also limit the AMQP protocol to only version 0.9 (which i believe is still widely used, but v1.0+ has been out for some time now as well).
Thoughts?
According to RabbitMQ specification they plan to support AMQP 0.9 indefinitely because 1.0 is completely different protocol. More info here.
The most know library Pika
does have support for Python 2.7, unlike aio-pika which is 3.4+. Pika should work fine for Apprise.
@caronc Any updates on this?
@gaby I have not forgotten this request, but i just have not gotten the time to tackle it. If you feel brave, you could try it yourself :slightly_smiling_face:
Even just a basic implementation of it by leveraging the new custom plugins you can write (see here). If you helped me with just the basics that you were expecting, it would save me some research with the library by using your code examples for a full implementation.
No worries, I will try to take a look :-)
One thing to consider is that there are 2 versions of AMQP that are both very active; v1.0 and v0.9.x
I presume we ant to try to support both?
- Apache Qpid seems to be a good route to go for v1.0 support
- And Pika i believe is the library of choice for v0.9.x versions
Hence the syntax i guess would be something like:
-
amqp://user:pass@host/topic?ver=1.0
-
amqps://user:pass@host/topic?ver=0.9
If no ver
is specified, then it would default to v1.0. It might be overkill to support both... or maybe not?
In the linked ticket (#656) there was reference to these platforms:
- https://cloud.google.com/pubsub
- https://aws.amazon.com/pub-sub-messaging/
Edit: I can't find on either cloud link above what version of AMQP they use.
@caronc Almost everything uses amqp 0.9.1, the v1.0 is a completely different protocol. More info [here] (https://stackoverflow.com/questions/28402374/amqp-0-9-1-vs-1-0).
I was recently doing an amqp implementation and it should be very straight forward to do using aio-pika
and the worker helper