ZeroMQ Pub/Sub with FlatBuffers Schemas

Typed, versioned messages between C++ and Python processes with zero-copy reads.

Owner: Priya RamanMission SoftwareContact ownerAdded 14 Jul 2026Updated 18 Sep 2026
  • Runs out of the box: yes
  • Tests: yes
  • CI: yes
  • Docs: yes
  • Used in production: no

Purpose#

A C++ publisher and a Python subscriber that share one FlatBuffers schema. Topics are prefixed with the schema version so a subscriber can ignore messages it cannot decode, and the build regenerates both language bindings from the same file.

The example also shows how to detect a slow subscriber with the high-water mark and how to record the stream to disk without copying message bodies.

What you will learn#

  1. Define a versioned FlatBuffers schema and generate C++ and Python bindings in CMake
  2. Wire PUB/SUB sockets with topic prefixes that encode the schema version
  3. Detect and report slow subscribers using the high-water mark
  4. Read fields without copying the message buffer

Media#

Technologies & features#

Technologies
C++PythonZeroMQFlatBuffersCMake
Features
Publish-Subscribe MessagingSchema-Driven Serialization
Topics
Messaging & IPCprimaryData & Persistence

Lessons learned#

  • Worked

    Encoding the schema version in the topic prefix let old subscribers keep running while a new publisher rolled out.

  • Didn’t work

    Relying on default socket buffers hid dropped messages. Setting a low high-water mark and logging the drop counter made the loss visible.

  • Decision

    PUB/SUB was chosen over request-reply because telemetry tolerates drops and publishers must never block on a subscriber.

Try it#

Shell
git clone https://git.example.internal/mission-software/zmq-fbs-pubsub.git
cd zmq-fbs-pubsub
cmake -S . -B build && cmake --build build -j2
./build/publisher &
python3 py/subscriber.py

Commands come from the owner’s README. Credentials are never stored here.

Resources#

Contributes to

StatusReference
OwnerPriya Raman
TeamMission Software
Last commit15 Sep 2026
Slugzeromq-flatbuffers-pubsub
Report a problem to the owner