Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zeromq - advantages of the router dealer pattern

Tags:

zeromq

Could anyone please provide a real-world example of using zmq with the router/dealer pattern, and explain its advantage over the more simple publish/subscribe pattern? Thanks.

like image 887
Mister_L Avatar asked Aug 26 '16 10:08

Mister_L


People also ask

What is ZeroMQ used for?

ZeroMQ provides a whole slew of language APIs which run on most operating systems and allows you to communicate seamlessly between all sorts of programs. It also provides a collection of patterns, such as request-reply and publish-subscribe which assist you in creating and structuring your network.

Does ZeroMQ use sockets?

ZeroMQ patterns are implemented by pairs of sockets with matching types. The built-in core ZeroMQ patterns are: Request-reply, which connects a set of clients to a set of services. This is a remote procedure call and task distribution pattern.


1 Answers

Dealers send their client ID with each message. Router is able to accept connections from multiple dealers and each time a message is received, it is able to discern which client sent the message. It is also able to send messages to specific clients by referring to their IDs.

Real life example: game server lets clients join a room until it is full. It keeps track of each client ID in the room. When room is full, it loops over each client ID within that room and sends them a "game started" message.

like image 78
nurettin Avatar answered Sep 26 '22 21:09

nurettin