ZeroMQ-based python message broker server/client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dave 373a9c5f15 be less noisy 2 years ago
examples fix port range arg 3 years ago
msgbus be less noisy 2 years ago
.gitignore misc fixes 3 years ago
Dockerfile Add dockerfile 3 years ago
README.md remove 127.0.0.1 hardcodings 3 years ago
requirements.txt misc fixes 3 years ago
setup.py refactor into package 3 years ago

README.md

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