Message-Publishing and -Subscribing
ØMQ supports a number of different message-passing patterns that work great in Node. We’ll start with the publish/subscribe pattern (PUB/SUB).
Recall the code we wrote in Chapter 3, Networking with Sockets, when we developed a networked file-watching service and a client to connect to it. They communicated over TCP by sending Line-Delimited JavaScript Object Notation (JSON) messages. The server would publish information in this format, and any number of client programs could subscribe to it.
We had to work hard to make our client code safely handle the message-boundary problem. We created a separate module dedicated to buffering chunked data and emitting messages. Even so, we were left with questions like ...
Get Node.js 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.