Consuming RESTful Java microservices with template interfaces using Eclipse MicroProfile Rest Client
No ratings yet
Learn how to use MicroProfile Rest Client to invoke RESTful microservices over HTTP in a type-safe way.Login to enroll
Classes StartMay 11, 2021
The application that you will be working with is an inventory service, which fetches and stores the system property information for different hosts. Whenever a request is made to retrieve the system properties of a particular host, the inventory service will create a client to invoke the system service on that host. The system service simulates a remote service in the application.
You will instantiate the client and use it in the inventory service. You can choose from two different approaches, Context and Dependency Injection (CDI) with the help of MicroProfile Config or the RestClientBuilder method. In this guide, you will explore both methods to handle scenarios for providing a valid base URL.
- When the base URL of the remote service is static and known, define the default base URL in the configuration file. Inject the client with a CDI method.
- When the base URL is not yet known and needs to be determined during the run time, set the base URL as a variable. Build the client with the more verbose RestClientBuilder method.