Calling other services

Finally, we may begin to implement the OrderController responsible for serving HTTP methods exposed outside a microservice. It has the RestTemplate bean injected to be able to call other HTTP endpoints. You may see in the following source code fragment that uses the Ribbon client name configured in application.yml instead of IP address or hostname. Using the same RestTemplate bean, we can communicate with three different microservices. Let's just take a second here to discuss the methods available inside the controller. In the first of the implemented methods, we call the GET endpoint from product-service, which returns a list with details of selected products. Then, we invoke the GET /withAccounts/{id} method exposed ...

Get Mastering Spring Cloud 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.