0

Consider a scenario: MasterApp( microservice 1) needs to call AssistApp( Microservice 2) to get data set A and tertiaryApp ( microservice 3) to get data set B. Each `Microservice ( 2 and 3) has 3 instance which needs to be load balanced( Ribbon is getting used for client side load balancing). Can you please let me know How should I prepare application.properties. I cannot put all 6 instance under property list of servers .

I have searched google( Dzone, nginx, spring examples in github and other forums), for a while but I was not able to find a conclusion for this Scenario.

RAHUL ROY
  • 126
  • 2
  • 13
  • 1
    You should choose a service registry such as eureka or consul. – spencergibb Mar 22 '19 at 16:28
  • I was using eurkea, but while doing the poc all the examples I was looking on net were enlisting the list of server in property file, so I was confused. Later on As @Chao Jiang suggested, I didn't need to know the uri and port number. – RAHUL ROY Mar 23 '19 at 11:10

1 Answers1

1

Generally, you shouldn't config anything in application.properties. I think you already have a param spring.application.name in your application.properties. And also, you have register your application into Eureka.

Then your call should be :

restTemplate.getForObject("http://SERVICE_NAME/xx/yy")

You don't need care about your 3 instance ip/port, just keep them the same application name.

Also, you should consider Feign, it will more convinced for your requirement.

Chao Jiang
  • 483
  • 3
  • 13