under construction under construction
Under construction


If you are using microservices, you would actually have to wait for a microservice registry to announce itself via broadcast notification. Then you could send your message to the registry, which then sends the message on to the microservice. Since there is more than one microservice registry, you will receive the announcement multiple times. And, of course, the node on which the microservice registry was installed can fall away at any time. You'd have to catch another notification for that.

The IMicroServiceRegistryCollector does all this for you. With its help, all you have to do is insert the microservice ID into the envelope of a message and send it.

However, sometimes it is necessary to communicate with the microservice registry itself. To obtain the address of a registry, the collector offers a few methods.

Getting the service

The service is available through the local service registry.

final IMicroServiceRegistryCollector collector = CServiceRegistry.getInstance()

As always, make sure that the service starter of your package has a dependency on the collector service to ensure that the service already exists.

Get the available microservice registries

The following method fetches all target addresses of the currently available microservice registries:

@NotNull Collection<CTargetAddress> getAddresses();

Get the nearest microservice registry

Usually it is enough to get the address of the nearest registry:

@Nullable CTargetAddress getNextAddress();

Send a message via collector to the microservice

If you have the address of a microservice registry, you can use this method to forward a message via this registry to a microservice. As method arguments you need the microservice ID, the message to send and the address (actually just the node address) of the registry. This method is used internally to send messages with microservice ID in the envelope to microservices.

void forwardToMicroService(@NotNull IId aId,
                           @NotNull CMessage aMessage,
                           @NotNull CNodeAddress aNodeAddress) throws CException;

Homepage of nyssr.net and RemoteSkin