2012/8/17 Pedro Melo <[email protected]>
> Hi,
>
> On Fri, Aug 17, 2012 at 2:17 PM, andrea crotti
> <[email protected]> wrote:
> >> In that situation then you want to use a forwarder device. The forwarder
> >> device binds to an incoming and an outgoing port. The publisher(s)
> connect
> >> to the incoming port and the subscriber(s) connect to the outgoing port
> of
> >> the device.
> >>
> >> All messages flow through the device to the subscribers. By using the
> >> intermediate device, the subscribers do *not* need to know about every
> >> possible publisher. It's a very neat and tidy solution.
> >
> > You mean something like this right? http://zguide.zeromq.org/py:wuproxy
>
> No, something like this:
>
> http://api.zeromq.org/3-2:zmq-device
>
>
Thanks I got it working:
def start_forwarder():
context = zmq.Context()
frontend = context.socket(zmq.SUB)
frontend.connect(TASK_FRONT)
frontend.setsockopt(zmq.SUBSCRIBE, '')
backend = context.socket(zmq.PUB)
backend.bind(TASK_BACK)
forw = zmq.device(zmq.FORWARDER, frontend, backend)
And is it the same thing as this right?
def start_proxy():
context = zmq.Context()
frontend = context.socket(zmq.SUB)
frontend.connect(TASK_FRONT)
frontend.setsockopt(zmq.SUBSCRIBE, '')
backend = context.socket(zmq.PUB)
backend.bind(TASK_BACK)
while True:
msg = frontend.recv()
more = frontend.getsockopt(zmq.RCVMORE)
if more:
backend.send(msg, zmq.SNDMORE)
else:
backend.send(msg)
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev