Skip to content

Instantly share code, notes, and snippets.

@beders
Created April 23, 2015 07:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save beders/7849cce449098d7e2de2 to your computer and use it in GitHub Desktop.
Bridging event bus
package com.saffrontech.ws.vertx.problem;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.ext.apex.Router;
import io.vertx.ext.apex.handler.sockjs.BridgeOptions;
import io.vertx.ext.apex.handler.sockjs.SockJSHandler;
// curl http://localhost:8888/eventbus/info
public class Server extends AbstractVerticle {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(Server.class.getName(), new DeploymentOptions());
}
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
BridgeOptions options = new BridgeOptions();
sockJSHandler.bridge(options);
router.route("/eventbus").handler(sockJSHandler);
vertx.createHttpServer().requestHandler(router::accept).listen(8888);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment