Is this approach is possible with NetMQ/ZeroMQ???

169 views
Skip to first unread message

Marcin Rogalski

unread,
Feb 3, 2017, 7:13:17 AM2/3/17
to netmq-dev
Hi,

I'm playing with NetMQ for a couple of days, and I really like it. You guys did an awesome job, so I decided to use it in our project (Dealer - Router pattern).

However, I have a question... I'm going to send multipart messages over the network between servers. Each message will consists of several frames;

1. Client Address (default)
2. Empty String (default)
3. Message Metadata (json string/byte[])
4. Message Payload

After send (Dealer), what I do in my app (on Router side) is, I read frame by frame using ReceiveFrameBytes: read Address (1), empty frame, then Message Metadata (point 3).
Based on the Metadata (point 3) - we perform validation. If validation fails, we DO NOT WANT TO LOAD LAST FRAME - Message Payload (I use SkipMultipartMessage method for that).

BUT... despite of fact that message is rejected/skipped, I see in Visual Studio Diagnostic Tool that the frame with Payload is loaded right after first ReceiveFrameBytes is called.

This is something which we can't accept (since when we have for instance: 10 x 5 MB Payloads, and Validation Engine (for example max allowed size is exceeded or Message Type is wrong) force the system to reject payloads - the MemoryUsage of my app is increasing anyway.

Is there any option to workaround that? To load messages frame by frame instead of reading entire message at a time?

I use latest NetMQ:   NetMQ 4.0.0.1

Any help would be very appreciated

Thanks in advance,
Marcin

Daniel Wonisch

unread,
Feb 15, 2017, 12:15:56 PM2/15/17
to netmq-dev
I'm using a similar approach using SkipFrame(), although my data is just around 1MB in size. In your case I think even by skipping the frame, your data will be send to client (socket.Receive will be called), the message is created but content is ignored and thrown away.

What you can do is to add an additional handshake between client and server. If the client is ready to receive data, tell the server to send, if not tell the server to throw it away.
Reply all
Reply to author
Forward
0 new messages