Calling one microservice from another with client-side load balancing
Remember how we configured our Eureka Server earlier to run on a separate port? Every microservice has to run on a distinct port. If we assume the images
service is our frontend (it has the Thymeleaf template, and is closest to consumers for serving up image data), then we can let it continue to run on Netty's default port of 8080
.
That leaves one decision: what port to run the comments
service on? Let's add this to the comments
service's application.yml
:
server: port: 9000
This setting instructs Spring Boot to run comments
on port 9000
. With that in place, let's go back to images
, and make some adjustments.
For starters (Spring Boot starters), we need to add some extra things to the images
build.gradle
file:
compile('org.springframework.cloud:spring-cloud-starter-eureka') compile('org.springframework.cloud:spring-cloud-starter-hystrix')
These changes include the following:
spring-cloud-starter-eureka
is...