Package org.zeromq

Examples of org.zeromq.ZContext.destroy()


            }
            System.out.printf("I: (%s) normal reply\n", identity);
            Thread.sleep(1000); //  Do some heavy work
            msg.send(worker);
        }
        ctx.destroy();
    }

}
View Full Code Here


        new Thread(new client_task()).start();
        new Thread(new server_task()).start();

        //  Run for 5 seconds then quit
        Thread.sleep(5 * 1000);
        ctx.destroy();
    }
}
View Full Code Here

                        msg.destroy();
                    }
                }
                client.send(String.format("request #%d", ++requestNbr), 0);
            }
            ctx.destroy();
        }
    }

    //This is our server task.
    //It uses the multithreaded server model to deal requests out to a pool
View Full Code Here

                new Thread(new server_worker(ctx)).start();

            //  Connect backend to frontend via a proxy
            ZMQ.proxy(frontend, backend, null);

            ctx.destroy();
        }
    }

    //Each worker task works on one request at a time and sends a random number
    //of replies back, with random delays between replies:
View Full Code Here

            statesub.connect("tcp://localhost:5003");
            fsm.state = State.STATE_BACKUP;
        }
        else {
            System.out.printf("Usage: bstarsrv { -p | -b }\n");
            ctx.destroy();
            System.exit(0);
        }
        //  .split handling socket input
        //  We now process events on our two input sockets, and process these
        //  events one at a time via our finite-state machine. Our "work" for
View Full Code Here

        }
        if (Thread.currentThread().isInterrupted())
            System.out.printf ("W: interrupted\n");

        //  Shutdown sockets and context
        ctx.destroy();
    }
}
View Full Code Here

        while (workers.size()>0) {
            ZFrame frame = workers.remove(0);
            frame.destroy();
        }
        workers.clear();
        ctx.destroy();
    }

}
View Full Code Here

        ZLoop reactor = new ZLoop ();
        PollItem item = new PollItem (arg.backend, ZMQ.Poller.POLLIN);
        reactor.addPoller (item, backendHandler, arg);
        reactor.start ();

        context.destroy ();
    }

}
View Full Code Here

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

            context.destroy ();
        }
    }

    /**
     * Worker using REQ socket to do load-balancing
View Full Code Here

                    break;

                msg.getLast ().reset ("OK");
                msg.send (worker);
            }
            context.destroy ();
        }
    }

    //Our load-balancer structure, passed to reactor handlers
    private static class LBBroker {
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.