This repository contains a simple gRPC API. The demo showcases how to set up and use gRPC in a real-world microservices scenario with a focus on implementing a gRPC service, client, and communication. It is designed to help developers understand the basics of gRPC and how to integrate it into your own projects.
gRPC is a high-performance, language-agnostic remote procedure call (RPC) framework developed by Google. It uses HTTP/2 for transport, Protocol Buffers (protobuf) as the interface definition language, and it is designed to make it easier to build efficient and robust distributed systems. gRPC is ideal for connecting microservices, enabling communication between client and server applications with low latency and high throughput.
This demo consists of the following service:
- Products Service: Handles product information
CreateProduct: Creates a new product
GetProduct: Retrieve the product details for the given id
DeleteProduct: Deletes the product with the given id
- Java 21 or higher
- Git
- Docker
git clone https://github.com/xxSlashxx/grpc-demo
cd grpc-demo
docker compose up
The service's endpoints can be accessed through grpc://localhost:9090
.
{
"name": "Clean Code",
"price": "29.99"
}
{
"id": "4"
}
{
"id": "4"
}
You can test the gRPC service using tools like Postman.
Configuration settings can be found in the application.properties files located in the service's src/main/resources directory. You can customize properties like database connections and port numbers.