Amity is a simple library to developing event driven systems using an AMQP backend.
This library allows you to create simple emitter and listeners along with slightly more complex requesters and responders.
The library also has built in support for django allowing you to extend signal outside of the web server and across the network.
Install and run rabbit-mq:
sudo apt-get install rabbitmq-server
Install the amity library:
pip install -e git+t://github.com/a-musing-moose/amity.git#egg=amity
Create a simple emitter:
from kombu.connection import BrokerConnection
from amity.messaging import Event, Emitter
connection = BrokerConnection('localhost', 'guest', 'guest', '/')
emitter = Emitter(connection)
emitter.emit('event.something', Event({"msg": "hello"}))
And a simple listener:
from kombu.connection import BrokerConnection
from amity.messaging import Event, Listener
connection = BrokerConnection('localhost', 'guest', 'guest', '/')
def on_message(event):
print "%s says: %s" % (event.get_header("from"), event.get("msg"))
listener = Listener(connection)
listener.add_callback("event.something", on_message)
listener.listen()
Then simple run your 2 scripts in separate terminals. The listener will sit and listen for any events that come in. Such as those produced by your emitter.
Contents: