I have a problem using ZMQ_PUB. I have a producer which connects to different processes that bind on ZMQ_SUB sockets.
When producer starts it creates s ZMQ_PUB socket and connects it to different processes. It then immediately start sending messages at a regular period.
As expected, if there are no connected subscribers, it drops all messages, until a subscriber starts. The flow works normal then, the subscriber start receives the messages. Now, the problem is :
- I disconnect the subscriber (stopping the process).
- There are no active subscriber at this point, as I stopped the only one.
- The producer continues sending messages, which should be dropped, as there are no connected subscribers anymore…
- I restart the original subscriber… and it receives all messages produced in the meantime !!
So what I see is that the producer enqueued all messages while the subscriber was down. As soon as the socket reconnected, because the subscriber process restarted, it sends all queued messages.
As I understood from here, a publisher should drop all sent messages when there are no connected subscribers:
As I am a "low-karma" user I can't publish a link to the documentation, which states :
"A publisher has no connected subscribers, then it will simply drop all messages."
Why is this happening?
By the way, I am using C++ over linux for these tests.
Thanks in advance,