Package org.zeromq.ZMQ

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


        else
            subscriber.connect("tcp://localhost:5556");

        Random rand = new Random(System.currentTimeMillis());
        String subscription = String.format("%03d", rand.nextInt(1000));
        subscriber.subscribe(subscription.getBytes());

        while (true) {
            String topic = subscriber.recvStr();
            if (topic == null)
                break;
View Full Code Here


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

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

    // get state snapshot
    snapshot.send("ICANHAZ?".getBytes(), 0);
        long sequence = 0;
    while (true) {
View Full Code Here

  public void run() {
    ZContext ctx = new ZContext();
    Socket subscriber = ctx.createSocket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5556");
    subscriber.subscribe("".getBytes());

    while (true) {
      kvsimple kvMsg = kvsimple.recv(subscriber);
            if (kvMsg == null)
                break;
View Full Code Here

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

            int count = 0;
            while (count < 5) {
                String string = subscriber.recvStr();
View Full Code Here

        {
            //  Subscribe to "A" and "B"
            Socket subscriber = ctx.createSocket(ZMQ.SUB);
            subscriber.connect("tcp://localhost:6001");
            subscriber.subscribe("A".getBytes());
            subscriber.subscribe("B".getBytes());

            int count = 0;
            while (count < 5) {
                String string = subscriber.recvStr();
                if (string == null)
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("".getBytes());

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

    // get state snapshot
View Full Code Here

        Socket statebe = ctx.createSocket(ZMQ.PUB);
        statebe.bind(String.format("ipc://%s-state.ipc", self));

        //  Connect statefe to all peers
        Socket statefe = ctx.createSocket(ZMQ.SUB);
        statefe.subscribe("".getBytes());
        for (argn = 1; argn < argv.length; argn++) {
            String peer = argv[argn];
            System.out.printf("I: connecting to state backend at '%s'\n", peer);
            statefe.connect(String.format("ipc://%s-state.ipc", peer));
        }
View Full Code Here

        Socket statebe = ctx.createSocket(ZMQ.PUB);
        statebe.bind(String.format("ipc://%s-state.ipc", self));

        //  Connect statefe to all peers
        Socket statefe = ctx.createSocket(ZMQ.SUB);
        statefe.subscribe("".getBytes());
        int argn;
        for (argn = 1; argn < argv.length; argn++) {
            String peer = argv[argn];
            System.out.printf("I: connecting to state backend at '%s'\n", peer);
            statefe.connect(String.format("ipc://%s-state.ipc", peer));
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 push = ctx.createSocket(ZMQ.PUSH);
    push.connect("tcp://localhost:5558");

    // get state snapshot
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

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.