From the course: Building Java Microservices with gRPC

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Write a client to call order service

Write a client to call order service

From the course: Building Java Microservices with gRPC

Start my 1-month free trial

Write a client to call order service

- [Instructor] As a first step to connect the user and the Order services as we recapped in the previous video, that'll be to write the gRPC Java client for the Order service. So let's head back to the IDE. And I will first add a package here, for our client classes. And under that I will create a class called OrderClient. What do we need to do here? We first need to get a stub object, which will help you make either a blocking or an asynchronous call to the service method. We're going to go ahead with a simple blocking call. So we need to get that stub. And next step will be to call the service method. These are the two things that we will need to do as a part of this class. But just to add a note here, when we get a stub object, we first need to get the HTTP/2 connection to the server that has to be set up first. So if you recall from a previous modules, we've known that whenever you want to establish an endpoint…

Contents