Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically update Eureka instance metadata

When Spring Cloud Eureka instance starts I can define some instance metadata statically (in eureka.instance.metadataMap.* in my application.yml) or dynamically (using EurekaInstanceConfigBean for example). But once instance is registered, this metadata no longer updates in Eureka after I update the config bean. Is there a way to define some metadata that will dynamically update in Eureka? So Eureka will work kind of like a key-value storage for each instance.

like image 452
FVlad Avatar asked Apr 04 '17 10:04

FVlad


People also ask

What is Eureka client serviceUrl defaultZone?

eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ In the preceding example, "defaultZone" is a magic string fallback value that provides the service URL for any client that does not express a preference (in other words, it is a useful default).

Which is the right Artifactid for the Eureka client dependency?

To include the Eureka Client in your project, use the starter with a group ID of org. springframework. cloud and an artifact ID of spring-cloud-starter-netflix-eureka-client . See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.

What is Eureka instance prefer IP address?

2.6 When to Prefer IP Address instance. preferIpAddress to true and, when the application registers with eureka, it uses its IP address rather than its hostname. If the hostname cannot be determined by Java, then the IP address is sent to Eureka. Only explict way of setting the hostname is by setting eureka.

How do I call Eureka instance?

Hit the URL http://localhost:8761/ in your web browser and you can see the Eureka Client application is registered with Eureka Server. Now hit the URL http://localhost:8080/ in your web browser and see the Rest Endpoint output.


1 Answers

If you want to update any metadata from eureka client for itself, just use com.netflix.appinfo.ApplicationInfoManagerobject and call registerAppMetadata(Map<String, String>). If so, this info will be updated in Eureka Server usually soon or at least in 30sec.You can use DI to get the instance of ApplicationInfoManger.

If you want to update metadata for other service instance, just invoke REST API like below to eureka server.

PUT /eureka/apps/appID/instanceID/metadata?key=value
like image 138
yongsung.yoon Avatar answered Dec 31 '22 20:12

yongsung.yoon