https://github.com/ivangfr/spring-boot-grpc-client-server
The goal of this project is to implement two Spring Boot applications using gRPC: the server, called movie-grpc-server, and the shell client, named movie-grpc-client. The library movie-grpc-lib defines the gRPC interface that both the server and client applications use.
https://github.com/ivangfr/spring-boot-grpc-client-server
client-server grpc java postgresql protocol-buffers sprind-data-jpa spring-boot spring-web-mvc
Last synced: 10 months ago
JSON representation
The goal of this project is to implement two Spring Boot applications using gRPC: the server, called movie-grpc-server, and the shell client, named movie-grpc-client. The library movie-grpc-lib defines the gRPC interface that both the server and client applications use.
- Host: GitHub
- URL: https://github.com/ivangfr/spring-boot-grpc-client-server
- Owner: ivangfr
- Created: 2024-08-29T13:17:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-26T18:55:34.000Z (about 1 year ago)
- Last Synced: 2025-04-05T07:31:38.960Z (10 months ago)
- Topics: client-server, grpc, java, postgresql, protocol-buffers, sprind-data-jpa, spring-boot, spring-web-mvc
- Language: Java
- Homepage:
- Size: 2.76 MB
- Stars: 16
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# spring-boot-grpc-client-server
The goal of this project is to implement two [`Spring Boot`](https://docs.spring.io/spring-boot/index.html) applications using [`gRPC`](https://grpc.io/): the server, called `movie-grpc-server`, and the shell client, named `movie-grpc-client`. The library `movie-grpc-lib` defines the `gRPC` interface that both the server and client applications use.
## Proof-of-Concepts & Articles
On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.
## Additional Readings
- \[**Medium**\] [**Implementing gRPC Server and Client using Spring Boot**](https://medium.com/@ivangfr/implementing-grpc-server-and-client-using-spring-boot-4411b26138be)
## Applications
- **movie-grpc-lib**
A Maven project that defines the `gRPC` interface (using [`Protocol Buffers`](https://protobuf.dev/)) for managing movies. This library is shared by both the `movie-grpc-server` and `movie-grpc-client` to ensure they can communicate properly over `gRPC`.
- **movie-grpc-server**
A Spring Boot web application that has `movie-grpc-lib` as dependency. It implements the `gRPC` functions for managing movies and runs a `gRPC` server to handle `movie-grpc-client` calls. The movies are stored in a [`PostgreSQL`](https://www.postgresql.org/) database.
- **movie-grpc-client**
A Spring Boot shell application that has `movie-grpc-lib` as dependency. It has a `stub` used to call `movie-grpc-server` functions.
## Packaging and Installing movie-grpc-lib
In a terminal and inside the `spring-boot-grpc-client-server` root folder, run the command below:
```
./mvnw clean install --projects movie-grpc-lib
```
## Start PostgreSQL Docker container
Run the command below to start `postgres` Docker container
```
docker run -d --name postgres \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=moviesdb \
postgres:17.2
```
## Running applications
- **movie-grpc-server**
In a terminal and inside the `spring-boot-grpc-client-server` root folder, run the following command:
```
./mvnw clean spring-boot:run --projects movie-grpc-server
```
- **movie-grpc-client**
Open another terminal, make sure you are in the `spring-boot-grpc-client-server` root folder. Then, run the command below to build the executable jar file:
```
./mvnw clean package --projects movie-grpc-client -DskipTests
```
Finally, to start the client shell, run:
```
./movie-grpc-client/target/movie-grpc-client-0.0.1-SNAPSHOT.jar
```
## Demo

## Shutdown
- To stop the applications, go to the terminals where they are running and press `Ctrl+C`;
- To stop the `postgres` Docker container, run:
```
docker rm -fv postgres
```