Messaging Patterns
Underneath the brown paper wrapping of ÃMQâs socket API lies the world of messaging patterns. If you have a background in enterprise messaging, or know UDP well, these will be vaguely familiar. But to most ÃMQ newcomers, they are a surprise because weâre so used to the TCP paradigm where a socket maps one-to-one to another node.
Letâs recap briefly what ÃMQ does for you. It delivers blobs of data (messages) to nodes, quickly and efficiently. You can map nodes to threads, processes, or nodes. ÃMQ gives your applications a single socket API to work with, no matter what the actual transport is (e.g., in-process, inter-process, TCP, or multicast). It automatically reconnects to peers as they come and go. It queues messages at both sender and receiver, as needed. It manages these queues carefully to ensure processes donât run out of memory, overflowing to disk when appropriate. It handles socket errors. It does all I/O in background threads. It uses lock-free techniques for talking between nodes, so there are never locks, waits, semaphores, or deadlocks.
But cutting through that, it routes and queues messages according to precise recipes called patterns. It is these patterns that provide ÃMQâs intelligence. They encapsulate our hard-earned experience of the best ways to distribute data and work. ÃMQâs patterns are hard-coded, but future versions may allow user-definable patterns.
ÃMQ patterns are implemented by pairs of sockets with matching types. ...
Get ZeroMQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.