Skip to content

rethinkdb/example-rabbitmq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integrating RethinkDB with RabbitMQ

Example code for connecting RethinkDB change feeds into RabbitMQ topic exchanges.

This repo contains an example integration for Python, Ruby, and JavaScript (NodeJS).

You can find a tutorial on the techniques behind these examples in javascript, python and ruby

Prerequisites

First, install RethinkDB. If you haven't already, you may want to have a look at the quickstart guide as well.

You'll also want to install RabbitMQ for your platform.

Finally, we recommend trying these out inside a virtualenv if you're using Python, and an rvm gemset if you're using Ruby.

Dependencies

Each script has two dependencies, the RethinkDB client and a library for interacting with RabbitMQ in that language. For Python that's pika, for Ruby it's Bunny, and for JavaScript it's amqplib (also known as amqp.node).

$ git clone http://github.com/rethinkdb/example-rabbitmq
$ cd example-rabbitmq/python
$ pip install -r requirements.txt
# or
$ cd example-rabbitmq/ruby
$ bundler install
# or
$ cd example-rabbitmq/javascript
$ npm install .

Rabbit feeder

The feeder script listens to changes to a RethinkDB table and inserts them into a RabbitMQ exchange as it's notified about them. Due to RethinkDB's changefeeds, there's no need to poll for table changes, the entire system is push/pull.

$ ./rabbit_feeder.py
# or
$ ./rabbit_feeder.rb
# or
$ ./rabbit_feeder.js

Rabbit listener

The listener script simply connects to the RabbitMQ instance and binds a queue to the rethinkdb exchange (created by the feeder script). It then prints out the changes coming through and what topic it received the message on. You'll want to run the listener in another window from the feeder:

$ ./rabbit_listener.py
# or
$ ./rabbit_listener.rb
# or
$ ./rabbit_listener.js

Change generator

This repo also contains a python script for generating random changes in the table the feeder scripts are subscribed to. This script isn't a part of the integration itself, but is useful for seeing changes happen in real-time. Again, you'll want to run the generator in a different window from the feeder and the listener.

$ ./change_generator.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published