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.
Instalación lista para agent
Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.
npx -y tokrepo@latest install 8dae1416-3734-11f1-9bc6-00163e2b0d79 --target codexEjecutar después de confirmar el plan con dry-run.
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.
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.
How to use
- Install the ZeroMQ library for your language.
- Create a socket with the desired pattern (PUB, SUB, REQ, REP, PUSH, PULL).
- Bind or connect the socket and start sending/receiving messages.
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)
Related on TokRepo
- AI Tools for DevOps -- Messaging and infrastructure tools
- Featured Workflows -- Top workflows on TokRepo
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.
Preguntas frecuentes
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.
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.
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.
Yes. ZeroMQ supports CurveZMQ encryption using elliptic-curve cryptography. Configure public/private key pairs on sockets for authenticated, encrypted communication.
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.
Referencias (3)
- ZeroMQ GitHub— ZeroMQ is a high-performance asynchronous messaging library
- ZeroMQ Guide— Socket patterns: pub/sub, req/rep, push/pull
- ZeroMQ Security— CurveZMQ encryption
Relacionados en TokRepo
Discusión
Activos relacionados
nanomsg — Socket Library for Scalable Messaging Patterns
Build distributed systems with a simple C library that provides common messaging patterns like pub/sub, request/reply, and pipeline.
RxJS — Reactive Programming Library for JavaScript
RxJS is a reactive extensions library for JavaScript using Observables for composing asynchronous and event-based programs. 100+ operators for transforming, filtering, and combining streams. The foundation of Angular and many complex UIs.
Signal Desktop — End-to-End Encrypted Messaging for Desktop
Signal Desktop is the official desktop client for the Signal private messenger. Built with Electron, it provides end-to-end encrypted messaging, voice notes, group chats, and disappearing messages on Linux, macOS, and Windows.
DearPyGui — High-Performance Python GUI Framework with GPU Rendering
A fast GPU-accelerated Python GUI toolkit built on Dear ImGui for data science, debugging, and interactive developer tools.