Quantcast
Channel: Active questions tagged zeromq - Stack Overflow
Viewing all articles
Browse latest Browse all 193

ZeroMQ High Water Mark Doesn't Work

$
0
0

when I read the "Durable Subscribers and High-Water Marks" in zmq guide, it said "The HWM causes ØMQ to drop messages it can't put onto the queue", but no messages lost when I ran the example. Hit ctrl+c to terminate the durasub.py and then continue it.

the example from the zmq in python.Other languages are the same.

durasub.py

import zmq                                              import time                                             context = zmq.Context()                                 subscriber = context.socket(zmq.SUB)                    subscriber.setsockopt(zmq.IDENTITY, "Hello")            subscriber.setsockopt(zmq.SUBSCRIBE, "")                subscriber.connect("tcp://localhost:5565")              sync = context.socket(zmq.PUSH)                         sync.connect("tcp://localhost:5564")                    sync.send("")                                           while True:                                                 data = subscriber.recv()                                print data                                              if data == "END":                                           break                                           

durapub.py

import zmq                                        import time                                       context = zmq.Context()                           sync = context.socket(zmq.PULL)                   sync.bind("tcp://*:5564")                         publisher = context.socket(zmq.PUB)               publisher.bind("tcp://*:5565")                    publisher.setsockopt(zmq.HWM, 2)                  sync_request = sync.recv()                        for n in xrange(10):                                  msg = "Update %d" % n                             publisher.send(msg)                               time.sleep(1)                                 publisher.send("END")                             

Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>