Limitations of hard coding microservice URLs

In the previous example, we added the following configuration to application.properties in the service consumer microservice:

    random-proxy.ribbon.listOfServers=      http://localhost:8080,http://localhost:8081

This configuration represents all instances of Microservice A. Take a look at these situations:

  • A new instance of Microservice A is created
  • An existing instance of Microservice A is no longer available
  • Microservice A is moved to a different server

In all these instances, the configuration needs to be updated and the microservices refreshed in order to pick up the changes.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.