Service self registration 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 the library is to provide self service registration. This library will listen when the service starts up/shuts down and will send the host and port on which is running and the healthcheck endpoint to the service registrar for registration.
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.self.service.registration</groupId>
<artifactId>mm.self.service.registration</artifactId>
<version>${service.self.registration}</version>
</dependency>
The current version of this library is 0.0.1-SNAPSHOT
After the library is included, you need to create a service.properties file located in the root of the resources folder. In this file you need to declare the following properties:
- service.id
- service.healthcheck.endpoint
- service.registration.endpoint
- service.deregisration.endpoint
- service.registrar.host
- service.useHostnameOverIP [optional]
service.id=testServiceOne
service.healthcheck.endpoint=/healthcheck
service.registration.endpoint=/register
service.deregisration.endpoint=/deregister
service.registrar.host=http://localhost:8080
service.useHostnameOverIP=false
service.id
is pretty much self explanatory, it represents the id of the service.
service.healthcheck.endpoint
is the endpoint where the service registrar will check if the service is active and running
service.registration.endpoint
is the endpoint where the service will send a POST request to registrar into the service registrar
service.deregisration.endpoint
is the endpoint where the service will send a GET request to deregistrar from the service registrar
service.registrar.host
is the URL where the service registrar is active
service.useHostnameOverIP
tells the library what type of URL to use when registering the service, URL containing the IP addres where the service is running or an URL containing the hostname.
After creating this file, when running the service, it will try to self register on the provided registration URL in the service.properties file. When shutting down the service, it will try to deregister on the provided deregistration URL in the service.properties file.