zeroMQ: Can someone please explain how HWM works?

7 views
Skip to first unread message

S M

unread,
May 23, 2017, 6:20:00 PM5/23/17
to zeromq

I'm experimenting with zeroMQ, I have a PUSH application that sends ~370000 messages each of 10Kb size. 

context = zmq.Context()
socket = context.socket(zmq.PUSH)
socket.bind("tcp://127.0.0.1:5557")

no_msgs = 0
i = 370000

fd = open("input_text_files/file1.txt", 'r')
msg = fd.read()

while i>0:
    print "Sending data of size" , len(msg)
    rc = socket.send(msg)
    no_msgs += 1
    if rc == None:
        print True
    if rc == -1:
        print "ERROR!!"

    i = i-1

The PULL application just received the messages in a loop:

context = zmq.Context()
socket = context.socket(zmq.PULL)
socket.connect("tcp://127.0.0.1:5557")

no_msgs = 1
i = 1

while True:
    msg = socket.recv()
    no_msgs += 1
    print "Received msg", i
    print "Received %s" %(len(msg))
    i = i + 1

With this setting, there are messages lost i.e., the PULL socket did not receive all 370000 messages. I added socket.hwm = 10 on the PUSH socket and all 370000 messages were received. Can someone explain to me how this works? Thank you!

Reply all
Reply to author
Forward
0 new messages