5 Clients for consuming other microservices

 

This chapter covers:

  • MicroProfile REST Client specification
  • Using Type Safe interfaces to consume external microservices
  • Customizing the content of headers on the request

While many microservices only require a database, alternative data services, or process a request within its own process, there will be times when a microservice needs to communicate with other microservices to fulfill a request. When shifting from monoliths to microservices, the tendency is towards smaller and leaner microservices which necessitates more of them. More importantly, many of those smaller microservices will need to communicate with each other to complete a task previously achieved with a single method calling other services inside a monolith. All those previous "in process" method calls are now external microservice invocations.

This chapter introduces the MicroProfile REST Client, and how Quarkus implements the specification to provide a Type safe means of interacting with external services. Though there are many possible approaches, including Javas' networking library, or third party libraries like okhttp and Apache HttpClient. Quarkus abstracts away the underlying HTTP transport construction from the developer, enabling them to focus on the task of defining the external service, and interacting with the service as if it were a local method invocation.

Figure 5.1. Banking Microservice consumption
05 consume microservice

5.1  What is MicroProfile REST Client?

5.2  Service Interface definition

5.2.1  CDI REST Client

5.2.2  Programmatic REST Client

5.2.3  Choosing between CDI and Programmatic API

5.2.4  Asynchronous response types

5.3  Customizing REST Clients

5.3.1  Client request headers

5.3.2  Declaring providers

5.4  Summary

sitemap