This project is a demonstration of using gRPC (Google Remote Procedure Call) with Spring Boot, facilitating communication between a client and server using protocol buffers.
-
GrpcServerService.java
:- This file defines the server-side implementation of the gRPC service. It contains a method
sayHello
which responds with a greeting message based on the received request.
- This file defines the server-side implementation of the gRPC service. It contains a method
-
hello.proto
:- This file specifies the protocol buffer messages and service definitions used for communication between the client and server. It defines two messages,
HelloRequest
andHelloResponse
, along with theGreetService
service containing thesayHello
RPC method.
- This file specifies the protocol buffer messages and service definitions used for communication between the client and server. It defines two messages,
-
GrpcServerServiceTest.java
:- This file contains JUnit tests for verifying the functionality of the gRPC server. It includes a test case for the
sayHello
method, ensuring that it returns the expected response.
- This file contains JUnit tests for verifying the functionality of the gRPC server. It includes a test case for the
-
SpringGrpcApplication.java
:- This is the main entry point of the Spring Boot application. It bootstraps the Spring context and starts the gRPC server.
To run the project, follow these steps:
- Ensure you have Java and Maven installed on your system.
- Clone this repository to your local machine.
- Navigate to the project directory.
- Run the following command to build the project:
mvn clean install
- Once the build is successful, you can start the server by running:
mvn spring-boot:run
- To run the tests, execute:
mvn test
- The server listens on port
9090
by default. You can modify this configuration inapplication.properties
if needed. - The client-side implementation for invoking the gRPC service is not included in this project. You can implement it using the generated stubs from the protocol buffer definitions. `