Package org.zeromq.ZMQ

Examples of org.zeromq.ZMQ.Socket.subscribe()


        @Override
        public void run(Object[] args, ZContext ctx, Socket pipe)
        {
            //  Subscribe to everything
            Socket subscriber = ctx.createSocket(ZMQ.SUB);
            subscriber.subscribe("".getBytes());
            subscriber.connect("tcp://localhost:5556");

            //  Get and process messages
            while (true) {
                String string = subscriber.recvStr();
View Full Code Here


        //      -p  primary server, at tcp://localhost:5001
        //      -b  backup server, at tcp://localhost:5002
        ZContext ctx = new ZContext();
        Socket statepub = ctx.createSocket(ZMQ.PUB);
        Socket statesub = ctx.createSocket(ZMQ.SUB);
        statesub.subscribe("".getBytes());
        Socket frontend = ctx.createSocket(ZMQ.ROUTER);
        bstarsrv fsm = new bstarsrv();

        if (argv.length == 1 && argv[0].equals("-p")) {
            System.out.printf("I: Primary active, waiting for backup (passive)\n");
View Full Code Here

    Socket snapshot = ctx.createSocket(ZMQ.DEALER);
    snapshot.connect("tcp://localhost:5556");

    Socket subscriber = ctx.createSocket(ZMQ.SUB);
        subscriber.connect("tcp://localhost:5557");
        subscriber.subscribe(SUBTREE.getBytes());

    Socket publisher = ctx.createSocket(ZMQ.PUSH);
    publisher.connect("tcp://localhost:5558");

        Map<String, kvmsg> kvMap = new HashMap<String, kvmsg>();
View Full Code Here

        // 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());
        while (!Thread.currentThread ().isInterrupted ()) {
            // Read envelope with address
            String address = subscriber.recvStr ();
            // Read message contents
            String contents = subscriber.recvStr ();
View Full Code Here

    Context context = ZMQ.context(1);

    //  First, connect our subscriber socket
    Socket subscriber = context.socket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5561");
    subscriber.subscribe("".getBytes());

    //  Second, synchronize with publisher
    Socket syncclient = context.socket(ZMQ.REQ);
    syncclient.connect("tcp://localhost:5562");
View Full Code Here

    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);
View Full Code Here

    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);
    }
View Full Code Here

    Socket send = context.socket(ZMQ.PUSH);
    send.connect("tcp://localhost:5001");

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

    Poller poller = new Poller(0);
    poller.register(receive, Poller.POLLIN);

    System.out.print("What is your name? ");
View Full Code Here

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.