Ryan N
Ryan N

Reputation: 669

ZeroMQ REQ-REP: Checking that replies went through

In the ZeroMQ documentation for a REP socket it says:

If the original requester doesn't exist any more the reply is silently discarded.

In my project, I'd like to have some way of knowing that the entity that made the original request is no longer present and listening for a reply. In other words, I'd like an error to be thrown if the reply is going to be discarded.

Is such a thing possible, or must I use some separate channel to check on the requestor or some kind of ACK upon its receipt of the reply?

Upvotes: 2

Views: 447

Answers (1)

pyfunc
pyfunc

Reputation: 66729

You should use a separate channel to track the requester since zmq sockets have no way to know that.

You could use request/reply sockets in reverse for that purpose but may suffer from performance issues because inherently you will be making another request/reply before making a reply.

Entity1                 Entity2
Request --------------   Reply
Reply   --------------   Request

and communication flow would be

Entity1 --------> request -----> Entity2
Entity1 <-------  request <----- Entity2
Entity1 --------  reply   ------> Entity2
Entity1 <-------  reply   ------- Entity2

This in now way provides guarantee that Entity1 would not be available for receiving the reply but improves it's probability.

How ever, it may not be a good idea to rquire requester state to be known to replier.

Upvotes: 1

Related Questions