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
From the course: Building Java Microservices with gRPC
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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Define order.proto and generate stubs6m 10s
-
(Locked)
Add database method to get orders8m 17s
-
(Locked)
Add service method to get order details6m 47s
-
(Locked)
Write code to host order service3m 48s
-
(Locked)
Test the order service using the client2m 57s
-
(Locked)
Recap to connect user and order services1m 50s
-
(Locked)
Write a client to call order service5m 14s
-
(Locked)
Call order client from user service7m 44s
-
(Locked)
Test the full flow of order management6m 43s
-
(Locked)
Challenge: Implement add-to-cart use case1m 33s
-
(Locked)
-