Can't specify > 1 instances for already created verticle

2,350 views
Skip to first unread message

Lizhang Li

unread,
Jan 29, 2016, 4:52:40 PM1/29/16
to vert.x

Hi,

I'm wondering how to deploy multiple verticle with guice injected instances. Got this error "Can't specify > 1 instances for already created verticle" when deploying 

vertx.deployVerticle(

  injector.getInstance(Verticle.class),

  new DeploymentOptions().setInstnaces(2).setWorker(true), res -> {}

);


Seems only way to deploy multiple verticle is to specify classname. Anyone experienced this issue as well? Thanks.

Abhishek Srinath

unread,
Sep 24, 2016, 11:17:54 PM9/24/16
to vert.x
Dont pass an instance - pass your verticle class name

Tim Fox

unread,
Sep 25, 2016, 3:45:23 PM9/25/16
to vert.x
You've already created your instance. Vert.x can't magically turn one instance of a Java object into N instances.

Roman Novikov

unread,
Dec 18, 2016, 2:29:04 AM12/18/16
to vert.x
How to passed additional params into verticle in this case? for example:

Verticle meVerticle = new MyVerticle(params);

Clement Escoffier

unread,
Dec 18, 2016, 12:24:07 PM12/18/16
to ve...@googlegroups.com
On 18 Dec 2016, at 08:29, Roman Novikov <myst...@gmail.com> wrote:

How to passed additional params into verticle in this case? for example:

Verticle meVerticle = new MyVerticle(params); 

You can’t set the number of instances if you pass an existing instance. Just use:

vertx.deployVerticle(MyVerticle.class.getName(), new DeploymentOptions().setInstances(4));

In this case, Vert.x instantiates 4 instances of your verticle using the default (no arg) constructor of your class.

Clement



On Sunday, September 25, 2016 at 10:45:23 PM UTC+3, Tim Fox wrote:
You've already created your instance. Vert.x can't magically turn one instance of a Java object into N instances.

On Friday, 29 January 2016 21:52:40 UTC, Lizhang Li wrote:

Hi,

I'm wondering how to deploy multiple verticle with guice injected instances. Got this error "Can't specify > 1 instances for already created verticle" when deploying 

vertx.deployVerticle(

  injector.getInstance(Verticle.class),

  new DeploymentOptions().setInstnaces(2).setWorker(true), res -> {}

);


Seems only way to deploy multiple verticle is to specify classname. Anyone experienced this issue as well? Thanks.


-- 
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9c6af4f1-9295-4860-924a-f33ff8313420%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roman Novikov

unread,
Dec 18, 2016, 12:32:33 PM12/18/16
to vert.x
but if I need to pass addition params to verticle how can I do this? Create static class for this purpose?

Julien Viet

unread,
Dec 18, 2016, 6:57:36 PM12/18/16
to ve...@googlegroups.com
Hi,

you need to use DeploymentOptions config JsonObject for configuring the verticles.

Julien

Reply all
Reply to author
Forward
0 new messages