getting all consumer addresses for an event bus

930 views
Skip to first unread message

ad...@cs.miami.edu

unread,
Mar 3, 2016, 12:45:32 AM3/3/16
to vert.x
Hi,

Given an instance of an EventBus, is there any way to obtain a list of all Strings that represent all addresses which have consumer handlers?

I am working on adding a function to help discover which services are on the bus.

When I create a consumer, I know I can get an instance of MessageConsumer, and from there grab the address, and put it in a list.  But I am looking for a solution that will do it live, regardless of if the info was captured initially when the consumer was registered.

Thanks,

-Adam


Tim Fox

unread,
Mar 3, 2016, 6:45:52 AM3/3/16
to ve...@googlegroups.com
I think a better way to implement this would be to create a "Service Registry" verticle which listens on the event by bus on a well known address.

When a service starts it can register itself with the registry and when it stops it can unregister itself.

If a client wants to know which services are registered it can then just ask the service registry.
--
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/777d0fff-6bca-4e94-ac13-45d993b5bf0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ian Andrews

unread,
Mar 3, 2016, 1:28:10 PM3/3/16
to vert.x
I have used the pattern that Tim describes quite successfully.  It is simple to implement, even if you want to have multiple copies of the same service.

Arnaud Estève

unread,
Mar 3, 2016, 1:43:15 PM3/3/16
to vert.x
I did too, in the past. Such an implementation along with vertx-service-proxy could be interesting to share. Maybe something like :

register(String name);
unregister(String name);

services(Handler<<List<String>>> subscribersHandler);

And maybe even extend AbstractVerticle to have a AbstractServiceVerticle which automatically registers/unregisters when it starts/stops with its className + deploymentId (or UUID).

wdyt ? Is this the pattern you've come up with ?
Reply all
Reply to author
Forward
0 new messages