title: ZMQ Pub Sub - Should it be dropping messages?
body: <p>Was trying to test a simple implementation of pub/sub. I am finding that if I leave subscriber up and send messages, they are not all received by Subscriber. Sometimes all are received, sometimes partial, sometimes whole set is not received. </p>
  
  <p>Run the Subscriber ( leave it running) , followed by running the Publisher multiple times. </p>
  
  <pre><code>import org.zeromq.ZMQ;
  import org.zeromq.ZMQ.Context;
  import org.zeromq.ZMQ.Socket;
  
  
  public static void main (String[] args) {
  
      // Prepare our context and subscriber
      Context context = ZMQ.context(1);
      Socket subscriber = context.socket(ZMQ.SUB);
  
      subscriber.connect("tcp://localhost:5563");
      subscriber.subscribe("B".getBytes());
  
  
      System.out.println("Starting Subscriber..");
      int i = 0;
      while (true) {
          String address = subscriber.recvStr();
          String contents = subscriber.recvStr();
          System.out.println(address+":"+new String(contents) + ": "+(i));
          i++;
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Publisher:</p>
  
  <pre><code>import org.zeromq.ZMQ;
  import org.zeromq.ZMQ.Context;
  import org.zeromq.ZMQ.Socket;
  
  
  public class TestPublisher {
  
  public static void main (String[] args) throws Exception {
      Context context = ZMQ.context(1);
      Socket publisher = context.socket(ZMQ.PUB);
      publisher.bind("tcp://*:5563");
      System.out.println("Starting Publisher..");
      publisher.setIdentity("B".getBytes());
      publisher.setHWM(1000);
      for (int i = 0; i &lt; 10; i++) {
          Thread.sleep(10l);
          publisher.sendMore("B");
          boolean isSent = publisher.send("We would like to see this:"+i);
          System.out.println("Message was sent "+i+" , "+isSent);
      }
  
      Thread.sleep(1000);
      publisher.close ();
      context.term ();
  }
  </code></pre>
  
  <p>}</p>