In my
App extends AbstractVerticle class's
main() method, I create a first instance of Vertx using only one
DeploymentOptions which is "
guice_binder" from
vertx-guice. Then, using this instance, I deploy the
App class itself as a first Verticle.
The aim is that in the
start() method of this first App Verticle, the
Guice context is now loaded and I have access to my configurations (which are wrapped inside a custom class), injected by Guice. So I can now do some validation to see which
DeploymentOptions to use for the "real" Vertx instance I need! For example :
VertxOptions vertxOptions = new VertxOptions();
if(myConfigsInjectedByGuice().getBoolean("environment.isDev")) {
vertxOptions.setBlockedThreadCheckInterval(1000*60*60);
}
Vertx realVertx = Vertx.vertx(vertxOptions);
And then, using this new Vertx instance, configured correctly, I can create my other Verticles, which would then :
1) Have access to the configurations injected by Guice.
2) Use the second Vertx instance, configured correctly.
My questions :
- Are there some issues to look for when creating a second Vertx instance like this?
- I get this warning message in the console doing so : "You're already on a Vert.x context, are you sure you want to create a new Vertx instance?". Should I be worried?
- Would the first Vertx instance
block some CPU's cores?
- Is there a better pattern to use Guice as soon as possible in a Vert.x app?
Thanks in advance!