Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ivangfr/spring-boot-grpc-client-server

This project aims to create two Spring Boot applications using gRPC: movie-grpc-server and movie-grpc-client. The movie-grpc-lib project defines the gRPC interface that both applications use.
https://github.com/ivangfr/spring-boot-grpc-client-server

client-server grpc java postgresql protocol-buffers spring-boot web

Last synced: 4 months ago
JSON representation

This project aims to create two Spring Boot applications using gRPC: movie-grpc-server and movie-grpc-client. The movie-grpc-lib project defines the gRPC interface that both applications use.

Awesome Lists containing this project

README

        

# spring-boot-grpc-client-server

This project aims to create two [`Spring Boot`](https://docs.spring.io/spring-boot/index.html) applications using [`gRPC`](https://grpc.io/): `movie-grpc-server` and `movie-grpc-client`. The `movie-grpc-lib` project defines the `gRPC` interface that both 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 `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:16.3
```

## Running applications

- **movie-grpc-server**

In a terminal and inside `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 `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

![demo](/documentation/demo.gif)

## 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
```