Skip to content

This repository provides a collection of examples showcasing the usage of gRPC in Java

License

Notifications You must be signed in to change notification settings

CharNikita/java-grpc-examples

Repository files navigation

Java gRPC Examples

A collection of Java gRPC examples demonstrating various concepts and features of the gRPC framework. Each example is a standalone project designed to showcase a specific aspect of gRPC in Java.

Table of Contents

Introduction

This repository contains a series of Java gRPC examples. Each example focuses on demonstrating a particular concept or feature of the gRPC framework in Java. The examples are located in the examples directory.

Prerequisites

  • Java 21

Examples

Each subdirectory within the examples folder represents a separate gRPC example project. These projects are independent of one another and can be explored individually.

  • example-echo-server: Basic Unary RPC echo server

Running the Examples

Each example project includes Gradle tasks to run the gRPC server and client applications.

Using Gradle Tasks

  1. Run the Server

    In one terminal window, execute:

    ./gradlew :example:EXAMPLE_NAME:runServer
  2. Run the Client

    In a separate terminal window, execute:

    ./gradlew :example:EXAMPLE_NAME:runClient

Assembling Distributions

Alternatively, you can assemble executable distributions for both the client and server.

  1. Assemble Server Distribution

    ./gradlew :example:EXAMPLE_NAME:assembleDistServer

    The distribution will be located in examples/EXAMPLE_NAME/build/distributions/.

  2. Assemble Client Distribution

    ./gradlew :example:EXAMPLE_NAME:assembleDistClient

    The distribution will be located in examples/EXAMPLE_NAME/build/distributions/.

  3. Run the Server

    Unzip the server distribution and execute the startup script:

    • On Unix/Linux/Mac:

      unzip build/distributions/Server.zip
      cd Server
      ./bin/Server
    • On Windows:

      unzip build\distributions\Server.zip
      cd server-distribution
      .\bin\Server.bat
  4. Run the Client

    Unzip the client distribution and execute the startup script:

    • On Unix/Linux/Mac:

      unzip build/distributions/Client.zip
      cd Client
      ./bin/Client
    • On Windows:

      unzip build\distributions\Client.zip
      cd Client
      .\bin\Client.bat

Contributing

Contributions are welcome! Please open an issue or submit a pull request with your improvements.

About

This repository provides a collection of examples showcasing the usage of gRPC in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published