Package org.zeromq.ZMQ

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


  private static Map<String, kvsimple> kvMap = new HashMap<String, kvsimple>();

  public void run() {
    Context ctx = ZMQ.context(1);
    Socket snapshot = ctx.socket(ZMQ.DEALER);
    snapshot.connect("tcp://localhost:5556");

    Socket subscriber = ctx.socket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5557");
    subscriber.subscribe("".getBytes());
View Full Code Here


    Context ctx = ZMQ.context(1);
    Socket snapshot = ctx.socket(ZMQ.DEALER);
    snapshot.connect("tcp://localhost:5556");

    Socket subscriber = ctx.socket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5557");
    subscriber.subscribe("".getBytes());

    // get state snapshot
    snapshot.send("ICANHAZ?".getBytes(), 0);
        long sequence = 0;
View Full Code Here

        String[] server = { "tcp://localhost:5001", "tcp://localhost:5002" };
        int serverNbr = 0;

        System.out.printf ("I: connecting to server at %s...\n", server [serverNbr]);
        Socket client = ctx.createSocket(ZMQ.REQ);
        client.connect(server[serverNbr]);

        int sequence = 0;
        while (!Thread.currentThread().isInterrupted()) {
            //  We send a request, then we work to get a reply
            String request = String.format("%d", ++sequence);
View Full Code Here

                    serverNbr = (serverNbr + 1) % 2;
                    Thread.sleep(SETTLE_DELAY);
                    System.out.printf("I: connecting to server at %s...\n",
                            server[serverNbr]);
                    client = ctx.createSocket(ZMQ.REQ);
                    client.connect(server[serverNbr]);

                    //  Send request again, on new socket
                    client.send(request);
                }
            }
View Full Code Here

        cloudbe.setIdentity(self.getBytes());
        int argn;
        for (argn = 1; argn < argv.length; argn++) {
            String peer = argv[argn];
            System.out.printf("I: connecting to cloud forintend at '%s'\n", peer);
            cloudbe.connect(String.format("ipc://%s-cloud.ipc", peer));
        }

        //  Prepare local frontend and backend
        Socket localfe = ctx.createSocket(ZMQ.ROUTER);
        localfe.bind(String.format("ipc://%s-localfe.ipc", self));
View Full Code Here

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

            while (true) {
                //  Send request, get reply
                client.send("HELLO", 0);
                String reply = client.recvStr(0);
View Full Code Here

            Context context = ZMQ.context(1);
            Socket worker = context.socket(ZMQ.REQ);
            ZHelper.setId (worker)//  Set a printable identity

            worker.connect("tcp://localhost:5671");

            int total = 0;
            while (true) {
                //  Tell the broker we're ready for work
                worker.send ("Hi Boss");
View Full Code Here

    private static ZMsg tryRequest (ZContext ctx, String endpoint, ZMsg request)
    {
        System.out.printf("I: trying echo service at %s...\n", endpoint);
        Socket client = ctx.createSocket(ZMQ.REQ);
        client.connect(endpoint);

        //  Send request, wait safely for reply
        ZMsg msg = request.duplicate();
        msg.send(client);
        PollItem[] items = { new PollItem(client, ZMQ.Poller.POLLIN) };
View Full Code Here

        //  Prepare our context and sockets
        Context context = ZMQ.context(1);

        //  This is where the weather server sits
        Socket frontend =  context.socket(ZMQ.SUB);
        frontend.connect("tcp://192.168.55.210:5556");

        //  This is our public endpoint for subscribers
        Socket backend  = context.socket(ZMQ.PUB);
        backend.bind("tcp://10.1.1.0:8100");
View Full Code Here

  private static AtomicLong sequence = new AtomicLong();

  public void run() {
    ZContext ctx = new ZContext();
    Socket subscriber = ctx.createSocket(ZMQ.SUB);
    subscriber.connect("tcp://localhost:5556");
    subscriber.subscribe("".getBytes());

    while (true) {
      kvsimple kvMsg = kvsimple.recv(subscriber);
            if (kvMsg == null)
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.