Dear list,

I’ve been playing around with how to ensure that a service has processed all 
messages that it has received (in the receiving socket queue) before shutting 
down. In particular, I’m using the rbczmq ruby bindings, so this question is 
also to see if those bindings are consistent with other languages.

Scenario:

A service has a ROUTER socket, bound to a tcp endpoint.
A client has a DEALER socket, connected to that tcp endpoint.
The client has sent one or more messages and is expecting a reply to each 
message.
The messages have been transmitted and are in the service’s inbound message 
queue waiting for processing.
The service receives a shutdown request (for example, a system being restarted 
for maintenance).
The service should process all received messages or store them for processing 
on next start-up.

—

When I do a socket.disconnect in the service, it is unable to read any message 
in the queue for that socket. However, if I subsequently connect that socket to 
a dummy endpoint, such as “ipc://foo”, then I can receive all of the messages 
in the queue that were sent to the real address. Once disconnected, the service 
is unable to send a response to the client, but at least the message can be 
saved, and a reply could be sent when the service comes back online.

The service should only be down for a small amount of time (just a few minutes 
I suppose) so for messages queued at the client side, this is not a problem 
because the client will wait for a reply and the io thread will continue to 
reconnect and send when it connects to the service.

Is the behaviour normal that socket.receive will fail with an error if the 
socket has no active endpoints (bind or connect)? I suppose this only makes 
sense for a non-blocking call, otherwise if there are no messages in queue, 
then the call will BlockForever™…

Also, I notice that if I disconnect/unbind the socket from the service, that 
ZMQ::Poller#poll and ZMQ::Socket#poll both report the socket as being readable, 
but reading from the socket still fails. Is this particular to rbczmq?


Cheers,
Matt

PS: happy holidays all!

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to