Skip to content

Instantly share code, notes, and snippets.

@kotcrab
Created February 21, 2022 15:16
Show Gist options
  • Save kotcrab/cc77db0ffaaf084d54ac08f5f8882e66 to your computer and use it in GitHub Desktop.
Save kotcrab/cc77db0ffaaf084d54ac08f5f8882e66 to your computer and use it in GitHub Desktop.
vertx-dropwizard-metrics issue
package com.example.starter;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
import io.vertx.ext.web.Router;
public class MainVerticle extends AbstractVerticle {
@Override
public void start(Promise<Void> startPromise) {
HttpServer server = vertx.createHttpServer();
Router router = Router.router(vertx);
router.route().handler(ctx -> {
HttpServerResponse response = ctx.response();
response.putHeader("content-type", "text/plain");
response.end("Hello World from Vert.x-Web!\n");
});
server.requestHandler(router).listen(8080, http -> {
if (http.succeeded()) {
System.out.println("Server started");
startPromise.complete();
} else {
startPromise.fail(http.cause());
}
});
}
public static void main(String[] args) {
var vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(
new DropwizardMetricsOptions().setJmxEnabled(true)
));
vertx.deployVerticle(new MainVerticle());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment