Created
May 18, 2016 16:08
-
-
Save IvanZelenskyy/9d50de8980b7bdf1e959e19593f7ce4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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