From fc0aac3b01bed6423bedd9f8557b133bf44cb850 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 4 Dec 2014 18:00:54 +0000 Subject: [PATCH] Add paragraph in docs about eureka instance id Fixes gh-63 --- .../main/asciidoc/spring-cloud-netflix.adoc | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/spring-cloud-netflix.adoc b/docs/src/main/asciidoc/spring-cloud-netflix.adoc index 8f54c077..42154ff8 100644 --- a/docs/src/main/asciidoc/spring-cloud-netflix.adoc +++ b/docs/src/main/asciidoc/spring-cloud-netflix.adoc @@ -10,7 +10,13 @@ include::intro.adoc[] Service Discovery is one of the key tenets of a microservice based architecture. Trying to hand configure each client or some form of convention can be very difficult to do and can be very brittle. Eureka is the Netflix Service Discovery Server and Client. The server can be configured and deployed to be highly available, with each server replicating state about the registered services to the others. -When clients register with Eureka, they provide eureka with meta-data about themselves such as host and port, health indicator URL, home page etc. Eureka receives heartbeat messages from each instance belonging to a service. If the heartbeat fails over a configurable timetable, the instance is normally removed from Eureka. +=== Registering with Eureka + +When a client registers with Eureka, it provide meta-data about itself +such as host and port, health indicator URL, home page etc. Eureka +receives heartbeat messages from each instance belonging to a service. +If the heartbeat fails over a configurable timetable, the instance is +normally removed from the registry. Example eureka client: @@ -64,6 +70,18 @@ ID, or VIP). See {github-code}/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaInstanceConfigBean.java[EurekaInstanceConfigBean] and {github-code}/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientConfigBean.java[EurekaClientConfigBean] for more details of the configurable options. +=== Making the Eureka Instance ID Unique + +By default a eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Using Spring Cloud you can override this by providing a unique identifier in `eureka.instance.metadataMap.instanceId`. For example: + +.application.yml +---- +eureka: + instance: + metadataMap: + instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}} +---- + === Using the DiscoveryClient Once you have an app that is `@EnableEurekaClient` you can use it to