Example usage for io.vertx.core.shareddata AsyncMap get

List of usage examples for io.vertx.core.shareddata AsyncMap get

Introduction

In this page you can find the example usage for io.vertx.core.shareddata AsyncMap get.

Prototype

default void get(K k, Handler<AsyncResult<@Nullable V>> resultHandler) 

Source Link

Document

Get a value from the map, asynchronously.

Usage

From source file:examples.SharedDataExamples.java

License:Open Source License

public void example4(AsyncMap<String, String> map) {

    map.get("foo", resGet -> {
        if (resGet.succeeded()) {
            // Successfully got the value
            Object val = resGet.result();
        } else {//from w  w w . j a va 2s  .  c  o  m
            // Something went wrong!
        }
    });

}

From source file:io.github.jdocker.serviceregistry.ServiceRegistry.java

License:Apache License

private void findEndpointInClusteredMapAndReply(String endpointName, Message<String> message, SharedData sd) {
    sd.<String, String>getClusterWideMap(REG_NAME, res -> {
        if (res.succeeded()) {
            AsyncMap<String, String> map = res.result();
            map.get(endpointName, result -> {
                if (result.succeeded()) {
                    final String endpointValue = result.result();
                    // TODO should we define any timeouts or anything else?
                    message.reply(endpointValue);
                }/*w w w  .ja va  2 s  .co  m*/
            });
        } else {
            // Something went wrong!
        }
    });
}