concept topology in category java

appears as: topologies, topology, The topology, Topology
Enterprise Java Microservices

This is an excerpt from Manning's book Enterprise Java Microservices.

Thorntail also provides a topology servlet, through the topology-webapp dependency, that sends server-sent events (SSEs) whenever services are registered or removed from the topology. The topology servlet works alongside any of the topology implementations from the preceding list. To see these events, add the following dependency to pom.xml:

<dependency>
  <groupId>io.thorntail</groupId>
  <artifactId>topology-webapp</artifactId>
</dependency>

After the microservice is running, either locally or in the cloud, open a browser to http://host:port/topology/system/stream to see the events showing the available instances. This allows a UI to visually represent the instances of each service that are present in the topology, as well as maintain a current list of which service instances are available for use.

You also can register services in a way that provides greater control over the timing of when a service is available, by using Topology.lookup(). Topology provides the main abstraction over each service registry implementation by offering methods for static lookup(), adding and removing listeners to be notified as services are added or removed, registering a microservice through advertise(), and retrieving all the current registry entries with asMap().

Whichever topology implementation you’ve chosen for your microservice—JGroups, OpenShift, or Consul—Topology is always available for a microservice to use directly.

Let’s say you want to use Topology to manually advertise and unadvertise a micro-service. One advantage to this approach is restricting the microservice from being added into the service registry until the RESTful endpoint is active and available to handle requests.