Package org.zeromq.ZMQ

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


                String peer = statefe.recvStr();
                String status = statefe.recvStr();
                cloudCapacity = Integer.parseInt(status);
            }
            if (primary[3].isReadable()) {
                String status = monitor.recvStr();
                System.out.println(status);
            }

            //  Now we route as many client requests as we have worker capacity
            //  for. We may reroute requests from our local frontend, but not from //
View Full Code Here


        //  Run for five seconds and then tell workers to end
        long endTime = System.currentTimeMillis() + 5000;
        int workersFired = 0;
        while (true) {
            //  Next message gives us least recently used worker
            String identity = broker.recvStr();
            broker.sendMore(identity);
            broker.recv(0);     //  Envelope delimiter
            broker.recv(0);     //  Response from worker
            broker.sendMore("");
View Full Code Here

                //  Tell the broker we're ready for work
                worker.sendMore("");
                worker.send("Hi Boss");

                //  Get workload from broker, until finished
                worker.recvStr();   //  Envelope delimiter
                String workload = worker.recvStr();
                boolean finished = workload.equals("Fired!");
                if (finished) {
                    System.out.printf("Completed: %d tasks\n", total);
                    break;
View Full Code Here

                worker.sendMore("");
                worker.send("Hi Boss");

                //  Get workload from broker, until finished
                worker.recvStr();   //  Envelope delimiter
                String workload = worker.recvStr();
                boolean finished = workload.equals("Fired!");
                if (finished) {
                    System.out.printf("Completed: %d tasks\n", total);
                    break;
                }
View Full Code Here

            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

        Socket responder = context.socket(ZMQ.REP);
        responder.connect("tcp://localhost:5560");

        while (!Thread.currentThread().isInterrupted()) {
            //  Wait for next request from client
            String string = responder.recvStr(0);
            System.out.printf("Received request: [%s]\n", string);

            //  Do some 'work'
            Thread.sleep(1000);
View Full Code Here

        //  Run for five seconds and then tell workers to end
        long endTime = System.currentTimeMillis () + 5000;
        int workersFired = 0;
        while (true) {
            //  Next message gives us least recently used worker
            String identity = broker.recvStr ();
            broker.sendMore (identity);
            broker.recvStr ();     //  Envelope delimiter
            broker.recvStr ();     //  Response from worker
            broker.sendMore ("");
View Full Code Here

        int workersFired = 0;
        while (true) {
            //  Next message gives us least recently used worker
            String identity = broker.recvStr ();
            broker.sendMore (identity);
            broker.recvStr ();     //  Envelope delimiter
            broker.recvStr ();     //  Response from worker
            broker.sendMore ("");

            //  Encourage workers until it's time to fire them
            if (System.currentTimeMillis () < endTime)
View Full Code Here

        while (true) {
            //  Next message gives us least recently used worker
            String identity = broker.recvStr ();
            broker.sendMore (identity);
            broker.recvStr ();     //  Envelope delimiter
            broker.recvStr ();     //  Response from worker
            broker.sendMore ("");

            //  Encourage workers until it's time to fire them
            if (System.currentTimeMillis () < endTime)
                broker.send ("Work harder");
View Full Code Here

                //  socket and resend the request. We try a number of times
                //  before finally abandoning:

                if (items[0].isReadable()) {
                    //  We got a reply from the server, must match sequence
                    String reply = client.recvStr();
                    if (reply == null)
                        break;      //  Interrupted
                    if (Integer.parseInt(reply) == sequence) {
                        System.out.printf("I: server replied OK (%s)\n", reply);
                        retriesLeft = REQUEST_RETRIES;
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.