title: Using ZeroMQ to send replies to specific clients and queue if client disconnects
body: <p>I'm new to ZeroMQ and trying to figure out a design issue. My scenario is that I have one or more clients sending requests to a single server. The server will process the requests, do some stuff, and send a reply to the client. There are two conditions:</p>
  
  <ul>
  <li>The replies must go to the clients that sent the request.</li>
  <li>If the client disconnects, the server should queue messages for a period of time so that if the client reconnects, it can receive the messages it missed. </li>
  </ul>
  
  <p>I am having a difficult time figuring out the simplest way to implement this.</p>
  
  <p>Things I've tried: </p>
  
  <ul>
  <li><p>PUB/SUB - I could tag replies with topics to ensure only the subscribers that sent their request (with their topic as their identifier) would receive the correct reply. This takes care of the routing issue, but since the publisher is unaware of the subscribers, it knows nothing about clients that disconnect.</p></li>
  <li><p>PUSH/PULL - Seems to be able to handle the message queuing issue, but looks like it won't support my plan of having messages sent to specific clients (based on their ID, for example).</p></li>
  <li><p>ROUTER/DEALER - Design seemed like the solution to both, but all of the examples seem pretty complex.</p></li>
  </ul>
  
  <p>My thinking right now is continuing with PUB/SUB, try to implement some sort of heartbeat on the client end (allowing the server to detect the client's presence), and when the client no longer sends a heartbeat, it will stop sending messages tagged with its topic. But that seems sub-optimal and would also involve another socket.</p>
  
  <p>Are there any ideas or suggestions on any other ways I might go about implementing this? Any info would be greatly appreciated. I'm working in Python but any language is fine.</p>