[zeromq-dev] how to implement the subscriber in the black box pattern

Pieter Hintjens ph at imatix.com
Thu Sep 19 09:46:53 CEST 2013


You can't connect a PUSH to a SUB; use a PUB socket to send the data.

On Thu, Sep 19, 2013 at 9:38 AM, Isaiah Turla <turlaisaiah at gmail.com> wrote:
> Hi i have this code
>
>     context = zmq.Context()
>
>     app_worker = context.socket(zmq.PUSH)
>     app_worker.bind("tcp://127.0.0.1:9005")
>
>     app_sub = context.socket(zmq.SUB)
>     app_sub.connect("tcp://127.0.0.1:9004")
>     app_sub.setsockopt(zmq.SUBSCRIBE,'JULES')
>
>     while True:
>         msg = app_sub.recv()
>         msg_data = msg.split(' ',1)
>         app_worker.send_json(msg_data[1])
>         print msg_data[1]
>
> but when i run this, it is unable to receive any message from the publisher,
> but when i remove the lines,
>
>     app_worker = context.socket(zmq.PUSH)
>     app_worker.bind("tcp://127.0.0.1:9005")
>
> it works normally, but i need it to be able to subscribe then process the
> message and then push it to another socket.
>
> what am i doing wrong?
>
>
> Isaiah Edward G. Turla
> BS Computer Science
> University of the Philippines Diliman
> Activities Committee Head - UP CURSOR
> turlaisaiah at gmail.com
>
> _______________________________________________
> 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