Package

Source Code of Subscriber

import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;

public class Subscriber {
  public static void main(String[] args) {
    Context context = ZMQ.context(1);

    Socket socket = context.socket(ZMQ.SUB);
    socket.connect("tcp://localhost:5000");

    socket.subscribe("tech".getBytes());
    socket.subscribe("music".getBytes());

    while (!Thread.currentThread().isInterrupted()) {
      String reply = socket.recvStr(0);
      System.out.println("Received " + reply);
    }

    socket.close();
    context.term();
  }
}
TOP

Related Classes of Subscriber

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.