Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.lang.IllegalArgumentException: Can't specify > 1 instances for already created verticle
- at io.vertx.core.impl.DeploymentManager.deployVerticle(DeploymentManager.java:70)
- at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:516)
- at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:511)
- at com.mycompany.world_map_service.web.starter.StarterVerticle.lambda$main$0(StarterVerticle.java:39)
- public static void main(String[] args) throws Exception {
- final Logger logger = Logger.getLogger(StarterVerticle.class);
- ClusterManager mgr = new HazelcastClusterManager();
- VertxOptions options = new VertxOptions().setClusterManager(mgr);
- Vertx.clusteredVertx(options, res -> {
- DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(config);
- if (res.succeeded()) {
- Vertx vertx = res.result();
- // Injector injector = Guice.createInjector(new AppInjector(vertx));
- Injector injector = Guice.createInjector(new AppInjector(vertx, deploymentOptions));
- vertx.deployVerticle(injector.getInstance(VertxHttpServerVerticle.class), deploymentOptions.setInstances(3));
- ...
- }
- public class AppInjector extends AbstractModule {
- private Vertx vertx = null;
- private Context context = null;
- DeploymentOptions deploymentOptions = null;
- public AppInjector(Vertx vertx, DeploymentOptions deploymentOptions) {
- this.vertx = vertx;
- this.context = vertx.getOrCreateContext();
- this.deploymentOptions = deploymentOptions;
- }
- @Override
- protected void configure() {
- bind(LocationService.class).to(LocationServiceImpl.class).in(Singleton.class);
- bind(LocationServiceDAO.class).to(LocationServiceDaoImpl.class).in(Singleton.class);
- bind(RedisRepo.class).toProvider(() -> {
- return new RedisRepo(deploymentOptions.getConfig());
- });
- bind(Neo4jRepo.class).toProvider(() -> {
- return new Neo4jRepo(deploymentOptions.getConfig());
- });
- }
- }
- vertx.deployVerticle(injector.getInstance(VertxHttpServerVerticle.class), deploymentOptions.setInstances(3));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement