From the course: Building Java Microservices with gRPC

Unlock the full course today

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

Write code to host the user service

Write code to host the user service

From the course: Building Java Microservices with gRPC

Start my 1-month free trial

Write code to host the user service

- [Instructor] Now that we've written the user service implementation which implements the server stub, let's go ahead and host that implementation on a server. For that we'll write a class UserServer. Let's go back to the IDE. I'll add a package here, which is for the server. And under this, I will create a class which is called UserServer. So this class is basically going to host the user service impl for us. Let's come under that. And first grab the logger in case we want to log anything. So I'll say, private static final logger. This is java.util.logging. getLogger and you just have to pass the name of the class. There we go. In addition to that, let's also grab the server from the io.grpc package. Let's grab a variable for that. Now we are going to write certain methods inside this UserServer class. The first one will be startServer. What is this method going to do for us? It is going to ensure…

Contents