2

I want to send data to a server from a client. Only the last message is important to the server. If the server comes up after a failure I only want the server to get the last message from the client.

While the server is down I want the client to keep processing and send messages or atlest put them in a queue(with the length of one message).

I try to use NetMQ/ZeroMQ for this. How can it be done?

Thanks!

Erik Z
  • 4,660
  • 6
  • 47
  • 74

1 Answers1

3

First use PubSub where the client is the publisher, with PubSub you will only get messages while you online, if the subscriber (server in your case) was down it missed all the messages (like a radio)

ZeroMQ also has a feature called Conflate (NetMQ doesn't have it yet, you might want to port it), take a look at the following question:

ZeroMQ: I want Publish–Subscribe to drop older messages in favor of newer ones

Also description of conflate from ZeroMQ documentation:

ZMQ_CONFLATE: Keep only last message If set, a socket shall keep only one message in its inbound/outbound queue, this message being the last message received/the last message to be sent. Ignores 'ZMQ_RCVHWM' and 'ZMQ_SNDHWM' options. Does not support multi-part messages, in particular, only one part of it is kept in the socket internal queue.

Community
  • 1
  • 1
somdoron
  • 4,653
  • 2
  • 16
  • 24