ZeroMQ-based python message broker server/client
Go to file
2017-09-17 20:45:57 -07:00
examples fix port range arg 2017-09-17 20:45:57 -07:00
msgbus fix port range arg 2017-09-17 20:45:57 -07:00
.gitignore misc fixes 2017-09-17 19:15:02 -07:00
README.md remove 127.0.0.1 hardcodings 2017-09-17 16:53:23 -07:00
requirements.txt misc fixes 2017-09-17 19:15:02 -07:00
setup.py refactor into package 2017-09-17 14:29:23 -07:00

pymsgbus

Simple zeromq-based pubsub client and server

Quick Start

  • Install: python3 setup.py install
  • Run server: mbusd -p 7100
  • Connect a peer server: mbusd -p 7200 --peer 127.0.0.1:7100
  • Dump events: mbussub -p 7100 --channel orderbook
  • Send events: mbuspub -p 7200 -c orderbook -m foo bar baz

About

Pymsgbus is server/client software for passing messages in a pub-sub pattern. It is built on top of pyzmq. This means you can use it with the native pymsgbus client or raw zeromq sockets. See msgbus/pub.py and msgbus/sub.py for examples.

Examples

Given the two peered servers created in Quick Start above, and these imports:

from contextlib import closing
from msgbus.client import MsgbusSubClient

This code would print out messages from the "orderbook" channel:

with closing(MsgbusSubClient(host, port)) as client:
    client.sub("orderbook")
    while True:
        channel, message = client.recv()
        print("On channel '{}' I got '{}'".format(channel, message))

And this code would send a message on the orderbook channel:

with closing(MsgbusSubClient(host, port)) as client:
    for message in messages:
        client.pub("orderbook", "hello world")

Because pymsgbus is built on ZeroMQ, you don't have to start the clients or servers in any specific order. You can start the lister client above and then the servers, and ZeroMQ will handle sorting things out. Of course, messages published when there's no server or no listeners are silently list.

TODO

  • Improve performance
  • Create docs