Skip to content

Instantly share code, notes, and snippets.

@pjagielski
Last active January 2, 2016 17:59
Show Gist options
  • Save pjagielski/8340712 to your computer and use it in GitHub Desktop.
Save pjagielski/8340712 to your computer and use it in GitHub Desktop.
Fast vert.x sender
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