Moksha provides a moksha.hub.MokshaHub
class that makes it simple for
applications to send messages to a given topic.
from moksha.api.hub import MokshaHub, reactor
hub = MokshaHub()
hub.send_message('topic', 'message')
reactor.run()
hub.close()
Behind the scenes, the MokshaHub
will automatically connect up to
whatever message brokers are configured, and create a new session. The
send_message()
method will automatically handle encoding your message to
JSON (unless you pass jsonify=False
), and sending it to the appropriate
message broker.
The CentralMokshaHub
is the primary consumer of all message topics
.
It runs outside of the Moksha WSGI application stack, and is automatically
started by the $ ./moksha-ctl.py start
or
$ ./moksha-ctl.py start:moksha-hub
commands (and can be started manually by running moksha-hub
).
The CentralMokshaHub
currently handles the following tasks: