Package org.zeromq.ZMQ

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


        router.bind("tcp://127.0.0.1:6001");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6001");

        Thread.sleep(1000);
        router.sendMore("A");
        router.sendMore(new byte[] {Persistence.MESSAGE_ERROR});
        router.send(new byte[] {Persistence.STATUS_INTERNAL_ERROR});
View Full Code Here


        router.bind("tcp://127.0.0.1:6002");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6002");

        Thread.sleep(1000);
        router.sendMore("A");
        router.sendMore(new byte[] {Persistence.MESSAGE_RESPONSE});
        router.sendMore(new byte[] {STATUS_OK});
View Full Code Here

        router.bind("tcp://127.0.0.1:6003");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6003");

        Thread.sleep(1000);
        router.sendMore("A");
        router.sendMore(new byte[] {Persistence.MESSAGE_FILE});
        router.sendMore(new byte[] {STATUS_OK});
View Full Code Here

        System.out.println("previous offset " + zlog.path().getAbsolutePath() + ":" + offset);

        sock.setIdentity(ZPUtils.genTopicIdentity(topic, 0));
        sock.setLinger(100);

        sock.connect("tcp://127.0.0.1:5557");


        boolean ret = sock.send(data);
        assertTrue(ret);
View Full Code Here

        System.out.println("previous offset " + zlog.path().getAbsolutePath() + ":" + offset);

        sock.setIdentity(ZPUtils.genTopicIdentity(topic, 0));
        sock.setLinger(100);

        sock.connect("tcp://127.0.0.1:5557");


        boolean ret = sock.send(data);
        assertTrue(ret);
View Full Code Here

        @Override
        public void run()
        {
            ZContext ctx = new ZContext();
            Socket worker = ctx.createSocket(ZMQ.REQ);
            worker.connect(String.format("ipc://%s-localbe.ipc", self));

            //  Tell broker we're ready for work
            ZFrame frame = new ZFrame(WORKER_READY);
            frame.send(worker, 0);
View Full Code Here

    public static void main(String[] args)
    {
        ZContext context = new ZContext();
        Socket subscriber = context.createSocket(ZMQ.SUB);
        if (args.length == 1)
            subscriber.connect(args[0]);
        else
            subscriber.connect("tcp://localhost:5556");

        Random rand = new Random(System.currentTimeMillis());
        String subscription = String.format("%03d", rand.nextInt(1000));
View Full Code Here

        ZContext context = new ZContext();
        Socket subscriber = context.createSocket(ZMQ.SUB);
        if (args.length == 1)
            subscriber.connect(args[0]);
        else
            subscriber.connect("tcp://localhost:5556");

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

    public static void main(String[] args) {
        Context context = ZMQ.context(1);

        //  Socket to talk to server
        Socket requester = context.socket(ZMQ.REQ);
        requester.connect("tcp://localhost:5559");
       
        System.out.println("launch and connect client.");

        for (int request_nbr = 0; request_nbr < 10; request_nbr++) {
            requester.send("Hello", 0);
View Full Code Here

        public void run() {
            ZContext ctx = new ZContext();
            Socket worker = ctx.createSocket(ZMQ.DEALER);
            worker.setHWM (-1);
            worker.setIdentity("W".getBytes());
            worker.connect("tcp://localhost:5556");
            while (!Thread.currentThread().isInterrupted()) {
                ZMsg msg = ZMsg.recvMsg(worker);
                msg.send(worker);
            }
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.