Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add instance to SimpleDiscoveryClient dynamically and programmaticaly - Spring Cloud

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.

like image 713
nassimerrahoui Avatar asked Dec 07 '25 03:12

nassimerrahoui


1 Answers

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

like image 71
nassimerrahoui Avatar answered Dec 10 '25 17:12

nassimerrahoui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!