2

I have an application that keeps computing stream data from T1(i.e 8:00 AM) to T2(i.e. 10:00 AM). I want to utilize the pyzmq to serve the data to clients by building a data server based on ZMQ.

For example, if a client connects to the server @8:10 AM, the server will send all old data before 8:10 AM and all new updates to the client. The client will get data based on the submitted topic list.

if the client connects to the server @7:00 AM, the server simply does nothing.

if the client connects to the server @11:00 AM, the server will send all available data from 8:00AM-10:00AM to the client and then close the connection.

Based on my understanding, I should use the Publish/Subscribe pattern. However, the a publisher has no connected subscribers, then it will simply drop all messages. This is NOT what I need.

https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/pubsub.html

Question> In my use case, how I should implement the client/server with ZMQ and which messaging pattern I should use?

Thank you

q0987
  • 34,938
  • 69
  • 242
  • 387
  • Publish and subcribe is "lossy". All clients get sent messages at the same time and those that aren't connected simply won't see the messages. If you need to ensure that clients see "missed" messages, you're going to need a different solution. – larsks Dec 14 '18 at 18:03
  • If in `zmq.SUB` side, don't use from `zmq.NOBLOCK` option, it waiting to receive a message from the `zmq.PUB` with buffering. However, you could use the `PUSH/PULL` pattern: in the `PUSH` side it waits for a `PULLER`. – Benyamin Jafari Dec 15 '18 at 07:32
  • Also check [this post](https://stackoverflow.com/a/47592338/3702377), maybe you need to change the `.bind()` and `.connect()` placement in `pub/sub` or `push/pull` – Benyamin Jafari Dec 15 '18 at 07:34

0 Answers0