↓ Skip to main content
  1. Home projects/

Messaging experiments: Redis and ZeroMQ

··

Two small experiments from the same week in July 2012.

queue-process: a Redis queue consumer
#

A multithreaded C++ client that pops events from a Redis list with a blocking BLPOP and hands them to a worker. Two Boost threads share the work through a mutex and a condition variable. A wrapper around the Redis client catches connection errors and retries every second, so the consumer survives Redis restarts. Source.

req-rep: ZeroMQ between C++ and Python
#

A ZeroMQ request-reply pair. The C++ server dispatches three-letter commands through a command map: GET returns the current message with its ID, and ACK<id> confirms it and moves on to the next one. The client is written in Python with Twisted and txZMQ: it loops GET and ACK, and if anything goes wrong, for example a timeout, it tears down the socket and starts again. Source.

Related