tags:

views:

57

answers:

2

If I set up a pipeline which distributes load across a cluster, I would like to log where the messages get sent. This is what I have in mind (python):

import zmq
context = zmq.Context()
socket = context.socket(zmq.DOWNSTREAM)
socket.connect("tcp://127.0.0.1:5000")
socket.connect("tcp://127.0.0.1:6000")

msg = "Hello World\0"
connection_string = socket.send(msg)
# should print "Sent message to tcp://127.0.0.1:5000"
print "Sent message to", connection_string

But I cant find anything that talks about this. Any help at all is appreciated.

A: 

It think you'll want to use the X(REP|REQ) sockets somewhere in the topology for this. You might want to checkout the monitered queue device: http://github.com/zeromq/pyzmq/blob/master/zmq/devices.pyx

And for general info have a look at the diagram and explanations of the patterns here too: http://ipython.scipy.org/doc/nightly/html/development/parallel_connections.html

Also note that the DOWNSTREAM socket type is now called PUSH (and the corresponding UPSTREAM has changed to PULL).

Ben Ford
A: 

Perhaps you could include the address of the recipient within the reply and log it then?

Jack Kelly