@LoadBalanced
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
Why We place @LoadBalanced on RestTemplate because RestTemplate is used to to fetch Server IP Address and port from Eureka Registry and its also used for Client side Load Balancing
@EnableEurekaClient public class MovieCatalogServiceApplication { public static void main(String[] args) { SpringApplication.run(MovieCatalogServiceApplication.class, args); } @Bean @LoadBalanced public RestTemplate getRestTemplate() { return new RestTemplate(); } }
See , In , Image Below, How Multiple Instances are registered of same application
We achieved by running application in an executable Jar in separate port
We achieved by running application in an executable Jar in separate port
java -Dserver.port=8084 -jar movie-info-service-0.0.1-SNAPSHOT.jar
No comments:
Post a Comment