Package org.zeromq.ZMQ

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


    public static void main(String[] args) {
        ZContext ctx = new ZContext ();
        Socket frontend = ctx.createSocket(ZMQ.ROUTER);
        Socket backend = ctx.createSocket(ZMQ.ROUTER);
        frontend.bind( "tcp://*:5555");    //  For clients
        backend.bind( "tcp://*:5556");    //  For workers

        //  List of available workers
        ArrayList<Worker> workers = new ArrayList<Worker> ();

        //  Send out heartbeats at regular intervals
View Full Code Here


        //  Prepare server socket with predictable identity
        String bindEndpoint = "tcp://*:5555";
        String connectEndpoint = "tcp://localhost:5555";
        Socket server = ctx.createSocket(ZMQ.ROUTER);
        server.setIdentity(connectEndpoint.getBytes());
        server.bind(bindEndpoint);
        System.out.printf ("I: service is ready at %s\n", bindEndpoint);

        while (!Thread.currentThread().isInterrupted()) {
            ZMsg request = ZMsg.recvMsg(server);
            if (verbose && request != null)
View Full Code Here

        @Override
        public void run(Object[] args, ZContext ctx, Socket pipe)
        {
            //  Prepare publisher
            Socket publisher = ctx.createSocket(ZMQ.PUB);
            publisher.bind("tcp://*:5556");

            while (true) {
                //  Send current clock (msecs) to subscribers
                String string = String.format("%d", System.currentTimeMillis());
                publisher.send(string);
View Full Code Here

        ZContext context = new ZContext();
        Socket publisher = context.createSocket(ZMQ.PUB);
        if (args.length == 1)
            publisher.connect(args[0]);
        else
            publisher.bind("tcp://*:5556");

        //  Ensure subscriber connection has time to complete
        Thread.sleep(1000);

        //  Send out all 1,000 topic messages
View Full Code Here

        public void run() {
            ZContext ctx = new ZContext();

            //  Frontend socket talks to clients over TCP
            Socket frontend = ctx.createSocket(ZMQ.ROUTER);
            frontend.bind("tcp://*:5570");

            //  Backend socket talks to workers over inproc
            Socket backend = ctx.createSocket(ZMQ.DEALER);
            backend.bind("inproc://backend");

View Full Code Here

            Socket frontend = ctx.createSocket(ZMQ.ROUTER);
            frontend.bind("tcp://*:5570");

            //  Backend socket talks to workers over inproc
            Socket backend = ctx.createSocket(ZMQ.DEALER);
            backend.bind("inproc://backend");

            //  Launch pool of worker threads, precise number is not critical
            for (int threadNbr = 0; threadNbr < 5; threadNbr++)
                new Thread(new server_worker(ctx)).start();

View Full Code Here

        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");
            frontend.bind("tcp://*:5001");
            statepub.bind("tcp://*:5003");
            statesub.connect("tcp://localhost:5004");
            fsm.state = State.STATE_PRIMARY;
        }
        else
View Full Code Here

            fsm.state = State.STATE_PRIMARY;
        }
        else
        if (argv.length == 1 && argv[0].equals("-b")) {
            System.out.printf("I: Backup passive, waiting for primary (active)\n");
            frontend.bind("tcp://*:5002");
            statepub.bind("tcp://*:5004");
            statesub.connect("tcp://localhost:5003");
            fsm.state = State.STATE_BACKUP;
        }
        else {
View Full Code Here

    public static void main(String[] args) {
        ZContext ctx = new ZContext ();
        Socket frontend = ctx.createSocket(ZMQ.ROUTER);
        Socket backend = ctx.createSocket(ZMQ.ROUTER);
        frontend.bind("tcp://*:5555");    //  For clients
        backend.bind("tcp://*:5556");    //  For workers

        //  Queue of available workers
        ArrayList<ZFrame> workers = new ArrayList<ZFrame> ();
       
        //  The body of this example is exactly the same as lruqueue2.
View Full Code Here

  @Test
  public void testSingleFrameMessage() {
    ZContext ctx = new ZContext();

    Socket output = ctx.createSocket(ZMQ.PAIR);
    output.bind("inproc://zmsg.test");
    Socket input = ctx.createSocket(ZMQ.PAIR);
    input.connect("inproc://zmsg.test");

    // Test send and receive of a single ZMsg
    ZMsg msg = new ZMsg();
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.