package bench.pubsub;

import org.zeromq.ZMQ;

/**
 * This sequencer simply reads from a PULL socket and forwards the
 * message to the PUB socket.
 */

public class ZeroMQSequencer {
    
    public static void main (String[] args) throws Exception {
        new Thread(new Sequencer()).start();
    }

    public static class Sequencer implements Runnable {
        public void run() {
            //  Prepare our context and publisher
            ZMQ.Context context = ZMQ.context(1);

            ZMQ.Socket publisher = context.socket(ZMQ.PUB);
            publisher.bind("tcp://*:5556");
            //publisher.bind("ipc://weather");

            ZMQ.Socket incoming = context.socket(ZMQ.PULL);
            incoming.bind("tcp://*:5557");

            while (! Thread.currentThread().isInterrupted()) {
                byte[] data = incoming.recv(0);
                //System.out.printf("Received message with %d bytes\n", data.length);
                publisher.send(data, 0);
            }

            publisher.close();
            incoming.close();
            context.term();
        }
    }
}

@@ -749,16 +749,69 @@
         
+ ZMQ.proxy(incoming, publisher, null);%0A            //
  while (
@@ -861,24 +861,27 @@
 %0A           
+ //
      byte%5B%5D 
@@ -912,24 +912,27 @@
 %0A           
+ //
      //Syste
@@ -1001,24 +1001,27 @@
 %0A           
+ //
      publish
@@ -1049,16 +1049,19 @@
         
+ //
  %7D%0A%0A    

Use ZMQ.proxy in the Sequencer.