Routing and Dealing Messages
The REQ/REP socket pair we explored makes request/reply logic easy to code by operating sequentially. The Node.js code for a given responder will only ever be aware of one message at a time.
For parallel message processing, ÃMQ includes the more advanced socket types ROUTER and DEALER. Letâs explore these a bit; then weâll be ready to construct our Node.js cluster.
Routing Messages
You can think of a ROUTER socket as a parallel REP socket. Rather than replying to only one message at a time, a ROUTER socket can handle many requests simultaneously. It remembers which connection each request came from and will route reply messages accordingly.
Recall from âImplementing a Messaging Protocolâ, that any time you ...
Get Node.js 8 the Right Way 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.