Skip to content

Instantly share code, notes, and snippets.

@IvanZelenskyy
Created May 18, 2016 16:08
Show Gist options
  • Save IvanZelenskyy/9d50de8980b7bdf1e959e19593f7ce4a to your computer and use it in GitHub Desktop.
Save IvanZelenskyy/9d50de8980b7bdf1e959e19593f7ce4a to your computer and use it in GitHub Desktop.
package com.example.tryRxVertx;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.shareddata.AsyncMap;
public class CallbackHellSetter extends AbstractVerticle {
@Override
public void start() throws Exception {
vertx.setPeriodic(300, event -> {
vertx.sharedData().<String,Long>getClusterWideMap("mymap", resOfGetMap -> {
if(resOfGetMap.succeeded()){
AsyncMap<String,Long> clusterMap = resOfGetMap.result();
Long newValue = System.currentTimeMillis();
clusterMap.put("timestamp", newValue, resOfPut -> {
if(resOfPut.succeeded()){
System.out.println("successfully updated value");
} else resOfPut.cause().printStackTrace();
});
} else resOfGetMap.cause().printStackTrace();
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment