Add instance to SimpleDiscoveryClient dynamically and programmaticaly - Spring Cloud

Viewed 399

My question concerns this project https://github.com/spring-cloud/spring-cloud-commons

Is there a way to add an instance to SimpleDiscoveryClient dynamically and programmaticaly during runtime instead of using application properties like here ?

Some ideas :

  • Create a custom implementation of SimpleDiscoveryClient
  • Create a list of static instances besides SimpleDiscoveryClient (create respectively spring cloud gateway routes) and get instances from my static list and others from SimpleDiscoveryClient

Thank you for your help.

1 Answers

Workaround : autowire SimpleDiscoveryProperties from SimpleDiscoveryClient to add an instance. Use ApplicationEventPublisher and send RefreshScopeRefreshedEvent to refresh Spring Cloud Gateway routes.

Related