Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. java.lang.IllegalArgumentException: Can't specify > 1 instances for already created verticle
  2. at io.vertx.core.impl.DeploymentManager.deployVerticle(DeploymentManager.java:70)
  3. at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:516)
  4. at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:511)
  5. at com.mycompany.world_map_service.web.starter.StarterVerticle.lambda$main$0(StarterVerticle.java:39)
  6.  
  7. public static void main(String[] args) throws Exception {
  8.  
  9. final Logger logger = Logger.getLogger(StarterVerticle.class);
  10.  
  11.  
  12. ClusterManager mgr = new HazelcastClusterManager();
  13. VertxOptions options = new VertxOptions().setClusterManager(mgr);
  14. Vertx.clusteredVertx(options, res -> {
  15. DeploymentOptions deploymentOptions = new DeploymentOptions().setConfig(config);
  16. if (res.succeeded()) {
  17. Vertx vertx = res.result();
  18. // Injector injector = Guice.createInjector(new AppInjector(vertx));
  19. Injector injector = Guice.createInjector(new AppInjector(vertx, deploymentOptions));
  20. vertx.deployVerticle(injector.getInstance(VertxHttpServerVerticle.class), deploymentOptions.setInstances(3));
  21. ...
  22. }
  23.  
  24. public class AppInjector extends AbstractModule {
  25.  
  26. private Vertx vertx = null;
  27. private Context context = null;
  28. DeploymentOptions deploymentOptions = null;
  29.  
  30.  
  31. public AppInjector(Vertx vertx, DeploymentOptions deploymentOptions) {
  32. this.vertx = vertx;
  33. this.context = vertx.getOrCreateContext();
  34. this.deploymentOptions = deploymentOptions;
  35. }
  36.  
  37.  
  38. @Override
  39. protected void configure() {
  40. bind(LocationService.class).to(LocationServiceImpl.class).in(Singleton.class);
  41. bind(LocationServiceDAO.class).to(LocationServiceDaoImpl.class).in(Singleton.class);
  42. bind(RedisRepo.class).toProvider(() -> {
  43. return new RedisRepo(deploymentOptions.getConfig());
  44. });
  45. bind(Neo4jRepo.class).toProvider(() -> {
  46. return new Neo4jRepo(deploymentOptions.getConfig());
  47. });
  48. }
  49. }
  50.  
  51. vertx.deployVerticle(injector.getInstance(VertxHttpServerVerticle.class), deploymentOptions.setInstances(3));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement