0PricingLogin
gRPC & High Performance APIs · Lesson

Simple Unary gRPC Service

Implement a basic 'request-response' gRPC service and client from scratch using generated code.

Unary RPC: Simple Interactions

In gRPC, a Unary RPC is the simplest communication pattern. It's like a traditional function call where a client sends a single request to the server, and the server responds with a single reply.

Think of it as a standard "request-response" model. The client waits for the server's response before proceeding.

  • Client sends one message.
  • Server sends one message back.
  • This is the most common RPC type.

Reviewing Our Protobuf

Before we dive into implementation, let's briefly recall our simple Protocol Buffer (Protobuf) definition. This schema defines the service and messages we'll use.

We'll implement the Greeter service with a SayHello method.

syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.example.grpc.helloworld";
option java_outer_classname = "HelloWorldProto";

package helloworld;

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

(Remember, code generation was covered in a previous lesson.)

All lessons in this course

  1. Protobuf Schema Definition
  2. Generating gRPC Code
  3. Simple Unary gRPC Service
  4. Streaming RPCs: Server, Client & Bidirectional
← Back to gRPC & High Performance APIs