---
title: "Messaging experiments: Redis and ZeroMQ"
description: "Two small 2012 experiments with message queues: a threaded Redis consumer in C++ and a ZeroMQ request-reply link between C++ and Python."
date: 2012-07-13T04:09:33-07:00
lastmod: 2026-10-16T18:58:52+02:00
url: https://klimek.link/projects/zeromq-redis-2012/
author: "Marcin Klimek"
source: https://klimek.link/projects/zeromq-redis-2012/
---

# Messaging experiments: Redis and ZeroMQ

Both of these small experiments come from the same week of July 2012.

## queue-process: a Redis queue consumer

queue-process is a multithreaded C++ client that pops events from a Redis list with a blocking `BLPOP` and hands them over to a worker, with two Boost threads sharing the work through a mutex and a condition variable. I wrapped the Redis client to catch connection errors and retry every second, so the consumer survives Redis restarts. [Source](https://github.com/marcinklimek/queue-process).

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

This one is a ZeroMQ request-reply pair. On the C++ side the server dispatches three-letter commands through a command map, where `GET` returns the current message together with the message ID and `ACK<id>` confirms that message and moves on to the next one. The client is written in Python with Twisted and txZMQ to loop GET and ACK, but if anything goes wrong (a timeout, for example), it tears down the socket and starts all over again. [Source](https://github.com/marcinklimek/req-rep).

*Diagram: The two experiments as message flows*

Source: https://klimek.link/projects/zeromq-redis-2012/
