4 Handling communications
This chapter covers
- Exposing and consuming APIs using the REST paradigm
- GraphQL as an alternative to the REST paradigm
- gRPC and Protocol Buffers as yet another way to expose and consume APIs
Microservices applications require a lot of network communication between the various parts. Recall that we plan to develop a system comprising the Users, Reservation, Rental, Inventory, and Billing services. All of these services need to exchange information between them. This communication can be synchronous, where an application that requires some data from another system makes a network call and waits for the result, or asynchronous, where the requesting service receives a notification of the result when it completes. In this chapter, we focus on synchronous communication since it still is the primarily utilized method of network communication in the microservices architecture. Specifically, we will learn how Quarkus makes it very easy to develop client and server applications that produce and consume data over the following protocols:
REST is a ubiquitous paradigm that probably doesn’t require a long introduction. Quarkus makes it easy to design your own REST API with a simple annotation-based model. We also learn how to write the client side—it’s just as easy since you can use the same annotations on the client.