...

/

Peer-To-Peer Publish/Subscribe with ZeroMQ

Peer-To-Peer Publish/Subscribe with ZeroMQ

Learn how to implement the Publish/Subscribe pattern using peer-to-peer messaging.

The presence of a broker can considerably simplify the architecture of a messaging system. However, in some circumstances, this might not be the best solution. This includes all the situations where a low latency is critically important, when scaling complex distributed systems, or when the presence of a single point of failure isn’t an option. The alternative to using a broker is, of course, implementing a peer-to-peer messaging system.

Introducing ZeroMQ

If our project is a good candidate for a peer-to-peer architecture, one of the best solutions to evaluate is certainly the ZeroMQ library(also known as zmq or ØMQ). ZeroMQ is a networking library that provides the basic tools to build a large variety of messaging patterns. It’s low-level, extremely fast, and has a minimalistic API, but it offers all the basic building blocks to create a solid messaging system, such as atomic messages, load balancing, queues, and many more. It supports many types of transport, such as in-process channels (inproc://), inter-process communication (ipc://), multicast using the PGM protocol (pgm:// or epgm://), and, of course, the classic TCP (tcp://).

Among the features of ZeroMQ, we can also find tools to implement a ...