Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 13, 2026·3 min de lecture

ZeroMQ — High-Performance Asynchronous Messaging Library

ZeroMQ (0MQ) is a high-performance asynchronous messaging library for distributed applications. It provides socket-like abstractions for message passing patterns — pub/sub, request/reply, push/pull — without the complexity of a full message broker.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
step-1.md
Commande d'installation directe
npx -y tokrepo@latest install 8dae1416-3734-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
ZeroMQ provides brokerless message passing with pub/sub, request/reply, and push/pull patterns.
§01

What it is

ZeroMQ (0MQ) is a high-performance asynchronous messaging library for distributed applications. It provides socket-like abstractions for common message passing patterns -- publish/subscribe, request/reply, push/pull, and dealer/router. Unlike Kafka or RabbitMQ, ZeroMQ requires no message broker; peers communicate directly.

ZeroMQ is for systems programmers and backend engineers building distributed applications that need fast, lightweight messaging without the operational overhead of a broker.

The project is actively maintained with regular releases and a growing user community. Documentation covers common use cases, and the open-source nature means you can inspect the source code, contribute fixes, and adapt the tool to your specific requirements.

§02

How it saves time or tokens

Broker-based messaging systems add infrastructure complexity and latency. ZeroMQ embeds directly into your application as a library, eliminating the broker entirely. Setup is one pip/npm/cargo install. Messages flow peer-to-peer with microsecond latency and millions of messages per second throughput.

§03

How to use

  1. Install the ZeroMQ library for your language.
  2. Create a socket with the desired pattern (PUB, SUB, REQ, REP, PUSH, PULL).
  3. Bind or connect the socket and start sending/receiving messages.
§04

Example

import zmq

# Publisher
context = zmq.Context()
pub = context.socket(zmq.PUB)
pub.bind('tcp://*:5555')
pub.send_string('topic hello world')

# Subscriber (separate process)
context = zmq.Context()
sub = context.socket(zmq.SUB)
sub.connect('tcp://localhost:5555')
sub.setsockopt_string(zmq.SUBSCRIBE, 'topic')
message = sub.recv_string()
print(message)  # 'topic hello world'
# Install
pip install pyzmq     # Python
npm install zeromq    # Node.js
brew install zeromq   # C library (macOS)
§05

Related on TokRepo

§06

Common pitfalls

  • ZeroMQ PUB/SUB drops messages if the subscriber connects after the publisher starts sending. Use a synchronization mechanism or a XPUB/XSUB proxy for reliable subscription.
  • ZeroMQ sockets are not thread-safe. Each thread must create its own context and sockets. Sharing sockets across threads causes undefined behavior.
  • There is no message persistence. If a consumer is offline, messages are lost. For durable messaging, use ZeroMQ with an application-level persistence layer or switch to NATS JetStream.

Before adopting this tool, evaluate whether it fits your team's existing workflow. Read the official documentation thoroughly, and start with a small proof-of-concept rather than a full migration. Community forums, GitHub issues, and Stack Overflow are valuable resources when you encounter edge cases not covered in the documentation.

Questions fréquentes

How is ZeroMQ different from RabbitMQ?+

RabbitMQ is a message broker that stores and routes messages centrally. ZeroMQ is a library that provides socket abstractions for direct peer-to-peer messaging. ZeroMQ has lower latency and no infrastructure to manage, but lacks built-in persistence and routing.

What messaging patterns does ZeroMQ support?+

ZeroMQ supports pub/sub, request/reply, push/pull (pipeline), dealer/router (async request/reply), pair, and exclusive pair. Each pattern is implemented as a socket type with specific send/receive semantics.

Which programming languages have ZeroMQ bindings?+

ZeroMQ has bindings for Python (pyzmq), C/C++, Java (JeroMQ), Node.js, Go, Rust, C#, Ruby, and many others. The core library is written in C++ with a stable C API.

Does ZeroMQ support encryption?+

Yes. ZeroMQ supports CurveZMQ encryption using elliptic-curve cryptography. Configure public/private key pairs on sockets for authenticated, encrypted communication.

Is ZeroMQ suitable for microservices?+

Yes, for services that need low-latency direct communication. ZeroMQ works well for internal service-to-service messaging where broker overhead is undesirable. For external-facing APIs or durable messaging, pair it with an API gateway or persistence layer.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires