Last active
January 2, 2016 17:59
-
-
Save pjagielski/8340712 to your computer and use it in GitHub Desktop.
Fast vert.x sender
This file contains 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
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.VoidHandler; | |
import org.vertx.java.core.eventbus.Message; | |
import org.vertx.java.platform.Verticle; | |
public class Sender extends Verticle { | |
public void start() { | |
send(0); | |
} | |
private void send(final int count) { | |
vertx.eventBus().publish("news-feed", "more news! [" + count + "]"); | |
if (count < 10000000) { | |
vertx.runOnContext(new VoidHandler() { | |
@Override | |
public void handle() { | |
send(count + 1); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment