[zeromq-dev] can use SUB and PUSH together with device?

Pieter Hintjens ph at imatix.com
Tue Jan 29 09:37:22 CET 2013


Hi,

Connecting a SUB to a PUSH is fine. The
http://api.zeromq.org/3-2:zmq-proxy page provides a few example proxy
configurations, but any combination of a readable socket and a
writeable socket will work.

-Pieter

On Tue, Jan 29, 2013 at 4:05 AM, timger™ <yishenggudou at gmail.com> wrote:
> hi all
> I want to recv message from pub broadcast
> and then distribute the message to some other process
>
> if I can use SUB and PUSH together with device?
>
> and some code like :
>
> import zmq
> import yaml
> from time import sleep
> conf = yaml.load(open('offline.yaml'))
>
>
> class Qsuber(object):
>
>     def __init__(self):
>         self.context = zmq.Context()
>         self.client_id = conf['clientid']
>         self.sub_connect()
>         self.push_bind()
>
>     def sub_connect(self):
>         self.socket = self.context.socket(zmq.SUB)
>         self.socket.setsockopt(zmq.SUBSCRIBE, "")
>         self.socket.setsockopt(zmq.IDENTITY, self.client_id)
>         self.socket.connect(conf['zmqsub'])
>
>     def push_bind(self):
>         sleep(0.1)
>         self.push_socket = self.context.socket(zmq.PUSH)
>         self.push_socket.setsockopt(zmq.HWM, 0)
>         self.push_socket.bind(conf['zmqpush'])
>
>     def recv(self):
>         zmq.device(zmq.STREAMER, self.socket, self.push_socket)
>
> if __name__ == "__main__":
>     main = Qsuber()
>     main.recv()
>
>
> timger™
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list