Package org.zeromq.ZMQ

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


        }
        //  Send one random update per second
        Random rand = new Random(System.currentTimeMillis());
        while (!Thread.currentThread().isInterrupted()) {
            Thread.sleep(1000);
            publisher.send(String.format("%03d", rand.nextInt(1000)), ZMQ.SNDMORE);
            publisher.send("Off with his head!");
        }
        context.destroy();
    }
}
View Full Code Here


        //  Send one random update per second
        Random rand = new Random(System.currentTimeMillis());
        while (!Thread.currentThread().isInterrupted()) {
            Thread.sleep(1000);
            publisher.send(String.format("%03d", rand.nextInt(1000)), ZMQ.SNDMORE);
            publisher.send("Off with his head!");
        }
        context.destroy();
    }
}
View Full Code Here

                        ZMsg msg = ZMsg.recvMsg(client);
                        msg.getLast().print(identity);
                        msg.destroy();
                    }
                }
                client.send(String.format("request #%d", ++requestNbr), 0);
            }
            ctx.destroy();
        }
    }
View Full Code Here

                        sendSingle(entry.getValue(), identity, subtree, socket);
                    }

                    //  Now send END message with getSequence number
                    System.out.printf("I: sending shapshot=%d\n", srv.sequence);
                    socket.send(identity, ZMQ.SNDMORE);
                    kvmsg kvmsg = new kvmsg(srv.sequence);
                    kvmsg.setKey("KTHXBAI");
                    kvmsg.setBody(subtree.getBytes());
                    kvmsg.send(socket);
                    kvmsg.destroy();
View Full Code Here

                snapshot.connect(String.format("tcp://localhost:%d", srv.peer));

                System.out.printf("I: asking for snapshot from: tcp://localhost:%d",
                        srv.peer);
                snapshot.sendMore("ICANHAZ?");
                snapshot.send(""); // blank subtree to get all

                while (true) {
                    kvmsg msg = kvmsg.recv(snapshot);
                    if (msg == null)
                        break;          //  Interrupted
View Full Code Here

            ZHelper.setId (client);     //  Set a printable identity

            client.connect("ipc://frontend.ipc");

            //  Send request, get reply
            client.send("HELLO");
            String reply = client.recvStr ();
            System.out.println("Client: " + reply);

            context.destroy ();
        }
View Full Code Here

          // receive message
          message = frontend.recv(0);
          more = frontend.hasReceiveMore();

          // Broker it
          backend.send(message, more ? ZMQ.SNDMORE : 0);
          if(!more){
            break;
          }
        }
      }
View Full Code Here

    client.setIdentity(id.getBytes());

    client.connect("ipc://frontend.ipc");

    //  Send request, get reply
    client.send("HELLO".getBytes(), 0);
    String reply = new String(client.recv(0));
    System.out.println("Client: " + reply);

  }
}
View Full Code Here

    worker.setIdentity(id.getBytes())//  Makes tracing easier

    worker.connect("ipc://backend.ipc");

    //  Tell backend we're ready for work
    worker.send("READY".getBytes(), 0);

    while(true)
    {
      String address = new String(worker.recv(0));
      String empty = new String(worker.recv(0));
View Full Code Here

      //  Get request, send reply
      String request = new String(worker.recv(0));
      System.out.println("Worker: " + request);

      worker.send(address.getBytes(), ZMQ.SNDMORE);
      worker.send("".getBytes(), ZMQ.SNDMORE);
      worker.send("OK".getBytes(), 0);
    }

  }
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.