Service registrar documentation - emiovska/microservices-monitoring GitHub Wiki
Every microservice can run one or more instances of it self anywhere on the cloud on different locations (host and port).
The main purpose of this library is to create an endpoints for registration and deregistration where the services can register/deregister. When a request for registration/deregistration comes in, the library will send a notification to the classes listening for this type of notifications.
To use this library first you need to add this lines in the pom.xml file
<repositories>
<repository>
<id>GitHub repository</id>
<url>https://github.com/RisteJovanoski/maven-repositories/raw/maven-repositories</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.emiovska.mm.service.registrar</groupId>
<artifactId>mm.service.registrar</artifactId>
<version>${service.registrar.version}</version>
</dependency>
The current version of this library is 0.0.1-SNAPSHOT
After the library is included, you need to create a service.registrar.version file located in the root of the resources folder. In this file you need to declare the following properties:
- registration.endpoint
- deregistration.endpoint
registration.endpoint=/register
deregistration.endpoint=/deregister
The both properties are pretty self explanatory, registration.endpoint
is the endpoint where the services will request their registration and the deregistration.endpoint
is the endpoint where the services will request their deregistration form the service registrar.
After creating this file, you need to implement the listener for the notifications sent by this library when request for registration/deregistration comes in.
To do this you need to create class and implement the ServiceStatusListener
interface. After that, when you want to register the listener, you need to get an instance of the ServiceStatusNotifier
through ServiceStatusNotifierManager.getNotifier()
and register the the listener with calling the registerListener
method. Whit this you are now ready for listening for registration/deregistration notifications.