Zero MQ is a library that has the ability to act as a messaging queue. But it is primarily a socket system that allows you to do concurrency, queuing and high availability to build distributed systems.
Zero MQ is a series of multiple queues that talk to each other. These can be 2 different machines, 2 separate processes on the same machine or 2 separate threads in the same process or any mix of those.
ZMQ is built around patterns. There are a few base patterns and you can implement advanced patterns on top of those patterns.

Queues are the basis of being able to do things asynchronously.
There are 5 Messaging Patterns in ZMQ:
- Sync Request/Response [ Post 2020 the default behavior is non-blocking ]
- Async Request/Response
- Publish/Subscribe
- Push/Pull
- Exclusive Pair
There are 6 Socket types:
- REQ
- REP
- PUSH
- PULL
- DEALER
- ROUTE
Any Message Queue has a common set of problems that must be addresses. For instance what if the Server cannot handle the load? What if we need more Servers? Before that we need to understand that a Message Queue needs the 3 following properties –
- Atomicity – [ once you send it, you receive it or you do not, you wont get a partial message ]
- String – ZMQ sends message as a String of bytes NOT a Stream of bytes. In a Stream you do NOT know when the message ends. In a String you know the size.
- Multi-Part – ?
- Queuing – Queues are the basis of being able to do things asynchronously.
Message Queue – A producer can produce a message to a centralized broker or something, a consumer can consume it. This is used to distributed and asynchronous processing. We can do in FIFO manner. The important thing is to guarantee that the message has been consumed once.
Message Queue is used to solve the limitation of the Request-Response architecture. Basically Request-Response is a blocking architecture. The Requester i.e. a Client is generally blocked till it gets a Response.
Pub-Sub is another pattern where a Publisher publishes a message and multiple Consumers can subscribe to something to consume that message.