2019年5月12日星期日

ZMQ Notes

ZMQ Important points

ZMQ is widely used as a reliable & easy-to-use replacement of sockets

Sync & A-Sync style sockets

In ZMQ, the sockets can be classified into two different categories:

  1. Sync: like REQ/REP
  2. Async: DEALER/ROUTER

Envelope

The concept of envelope is used to identify the source of each message.
For REQ socket,

  1. Send the message: REQ will prepend a empty frame to the real message.
  2. Receive the message: strips every frame including empty frame.

For REP socket:

  1. Receive the message: Will strip frames including empty frame, then return the rest of the message to application.
  2. Send the message: Prepend the message with saved envelope.

For ROUTER socket:

  1. Receive the message: prepend identify frame automatically
  2. Send the message: Remove the identity frame and check existence of the identity.

For DEALER socket: Do nothing, will send whatever you want in the message.

Written with StackEdit.