Passing Object to Embedded Vertx Verticle

1,141 views
Skip to first unread message

Evgeny Shenker

unread,
Jan 28, 2016, 4:49:56 AM1/28/16
to vert.x

Hello!
Having embedded vertx instance that deploys services and verticles how can we pass Object that was created
early in embedding application to verticles that are running?
We tried to use context on vertx instance, but it seems to be different for verticles and does not contain the object
that was put.

Thanks.

Clement Escoffier

unread,
Jan 28, 2016, 5:00:50 AM1/28/16
to ve...@googlegroups.com
Hello,

What do you mean by “pass Object” ?

You can configure each verticle by specifying a configuration in the deployment options (a parameter of vertx.deployVerticle).
If the verticle needs to “interact”, I would recommend using the event bus to send and receive messages. 

Clement

--
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/285bbebc-1735-48a9-ace7-bcb3a0d11d15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evgeny Shenker

unread,
Jan 28, 2016, 6:00:36 AM1/28/16
to vert.x
Hey!
Thanks for the answer.
The reason for passing object is that its not serializable so it can not be passed via event bus.
The object is just some logic that is initiated and used by application and now is needed by verticles to perform its functionality.
I can probably use static references to get access to the object from vertcle since its the same process and there is no classloader issues.
Just think that maybe there is more convenient way to do this.
Maybe some repository for beans that can be accessed from vertx container.
Thanks
Any thoughts?

Julien Viet

unread,
Jan 28, 2016, 6:05:07 AM1/28/16
to ve...@googlegroups.com
you can deploy directly java verticle instance if you like. so you can instantiate yourself this verticle and pass it the object in constructor or later (beware it won’t probably be the same thread than running the verticle).

Evgeny Shenker

unread,
Jan 28, 2016, 8:03:00 AM1/28/16
to vert.x
Hey!

Thanks for the answer.
Its definitely the solution.
The problem in my case is that verticle and services are currently implemented in groovy script and also the idea was to use
the bean in vertx service (proxed), that is auto generated. I understand that i can manually register the implementation.
I guess that the thread will be  different too. Probably vertx will spawn its own threads and not use the application one that created it.

Thanks all.
Reply all
Reply to author
Forward
0 new messages