Reputation: 131
I am new to ZeroMQ ( on C++ ).?br:
While writing a program with a PUB/SUB
Formal Communication Pattern archetype, I am stuck with a problem.
Program :
It's my Project, where I suppose to send as much as possible messages to a PUB
.
For this I used to use a ROUTER
socket-type.
Problem :
Receiver is slow, due to which messages are getting queued ( up until reaching the high watermark ) and after that, starts dropping on SUB
side.
Looking for :
I want a method from ZeroMQ ( on C++ ), which tells me a "Count of Messages in Outstanding Queue".
Searched a lot but did not find any answer.
I am looking for any kind of pointer OR help on this.
Upvotes: 1
Views: 2288
Reputation: 131
Found the Answer. Using 3 parameter under Router type, I was able to solve it. in zmq.hpp we have send(which goes till router->send method). at router level we have multiple checks like ( queue is full or packet is not getting delivered, etc) If we set * router mandator / sendtimeout(-1)/ and send packet with dontwait then zmq send will handle all errors/re-try (including zmq queue full OR HWM hit).
Upvotes: 2
Reputation: 1
It sounds like you are using asynchronous messaging. This means that the sender will have no knowledge of message arrival and/or queuing. Can you try using a static counter, which you'll increment each time the sender sends a message, and another static variable that you'll increment when the receiver gets a message? Taking the difference of these two should tell you how many messages are possibly queued up. It might give you more insight, although this should be experimental as it is not safe. What you should rather focus on is optimizing the SUB so that it does not drop any messages. Check the rate and see if you can work around that. Alternatively, you can create your own buffer, which you'll use to store incoming messages, if your processing causes the latency.
Upvotes: 0