Open goforgold opened 3 years ago
I think I have found a solution by having a separate NetMQPoller
for RouterSocket
and NetMQQueue
. Now Queue_ReceiveReady
is triggered immediately as I enqueue messages in NetMQQueue
.
I wish if we could document this part properly and highlight this use case.
@somdoron Could you please let us know about some technicalities behind this behaviour? I can then try raising a pull request for documentation changes.
I have implemented a router-dealer strategy in my server and client application. I need to send a large set of data (up to 5 GB) from the server (router) to the client (dealer). I am trying to send this data in chunks instead of a full large message to save memory as well as to allow the client to read data in parallel.
I have defined my RouterSocket and NetMQPoller in the following manner.
Definition of
Queue_ReceiveReady
andSocketServer_ReceiveReady
looks like below:I am enqueuing messages in a loop similar to below.
EnqueueMessage
is defined as below:Expected behaviour
I expect my messages to hit
Queue_ReceiveReady
each time (or after a fewEnqueue
calls) so I can actually wire messages to the client in chunks as I am reading from my database.Actual behaviour
Queue_ReceiveReady
only starts triggering when my loop has finished. When debugging the issue, I see logs in the below sequence.This behaviour is not allowing me to use memory efficiently as I see that memory usage increases to up to 7 GB and then starts reducing when
Queue_ReceiveReady
starts trigerring.Is this the expected behaviour of NetMQPoller? What is the fix or workaround to actually wire multiple messages in a loop to a dealer?