Reputation: 33392
From a book "A gentle guide to asynchronous programming with Eclipse Vert.x for Java developers" I know how to deploy HTTP handler in Vert.x from a single verticle:
HttpServer server = vertx.createHttpServer();
Router router = Router.router(vertx);
router.get("/").handler(this::getRoot);
router.post("/").handler(this::postRoot);
server
.requestHandler(router::accept)
.listen(portNumber, ar -> { ... });
This is all great but later I need to define getRoot
and postRoot
methods in the same class (of course I can use a different class here) and "register" these functions into a router in a single, main "HTTP orchestration verticle". Those functions can use event bus and call other verticles, but the registration phase seems to be a bottleneck here: what if I need to handle dozens / hundreds / thousands of URLs? This apprioach won't scale.
Is there a way to split HTTP router configuration between multiple verticles in Vert.x so I can just implement my logic in separate classes without the need to register it somewhere else?
Upvotes: 2
Views: 622
Reputation: 9128
You can't split router config over different verticles.
If you have lots of handlers, use Sub-Routers
Upvotes: 4