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.

Call order client from user service

Call order client from user service

From the course: Building Java Microservices with gRPC

Start my 1-month free trial

Call order client from user service

- [Instructor] The next step will be to invoke that order client that we just created in the user service implementation. So let's head back to the IDE. And in the UserServiceImpl class, let's put a comment here, that we are getting orders by invoking the order client. Okay. So what do we need to do for this? The first step is to create that channel. Let's establish an endpoint connection with the order service. That will be represented by an API called ManagedChannel. And how do we create this? There's a builder for it which has a method called forTarget on it. So we're creating an HTTP/2 connection for the order service, and the target URL for the order service,| we already know, is localhost 50052. So that is what we will feed to that forTarget method. In addition to this, let us just use a plain text for this channel. And then build this object. Once we do this, let's instantiate that order client.…

Contents