Publish and subscribe entirely in RethinkDB

With RethinkDB’s changefeeds, it’s easy to create a publish-subscribe message exchange without going through a third-party queue. Josh Kuhn has written a small library, repubsub, that shows you how to build topic exchanges—and he’s written it in all three of our officially-supported languages. He’s put together a terrific tutorial article demonstrating how to use it. You can simply create a topic and publish messages to it:

topic = exchange.topic('fights.superheroes.batman')
topic.publish({'opponent': 'Joker', 'victory': True})

Then subscribe to just the messages that match your interest.

filter_func = lambda topic: topic.match(r'fights\.superheroes.*')
queue = exchange.queue(filter_func)
for topic, payload in queue.subscription:
    print topic, payload

Josh describes how to implement tags, nested topics and more, so check out the publish-subscribe tutorial.