https://github.com/ivan-montes/hello-armeria
Hanging out with Spring and Armeria
https://github.com/ivan-montes/hello-armeria
armeria grpc java rest-api spring
Last synced: 3 months ago
JSON representation
Hanging out with Spring and Armeria
- Host: GitHub
- URL: https://github.com/ivan-montes/hello-armeria
- Owner: Ivan-Montes
- License: gpl-3.0
- Created: 2024-12-20T06:39:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-24T08:14:15.000Z (over 1 year ago)
- Last Synced: 2025-07-18T10:52:23.954Z (12 months ago)
- Topics: armeria, grpc, java, rest-api, spring
- Language: Java
- Homepage:
- Size: 171 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# hello-armeria
Hanging out with [Spring](https://spring.io/) and [Armeria](https://armeria.dev/)
### Components
| Name | gRPC Port | Web Port | Docs |
|-----|-----|-----|-----|
| rest-service | x | 8081 | 8091 |
| rest-service-reactive | x | 8082 | 8092 |
| rest-service-reactive-functional | x | 8083 | 8093 |
| grpc-service | 50051 | x | 50051 |
| grpc-service-reactive | 50052 | x | 50052 |
| grpc-service-transcoding | 50053 | x | 50053 |
| grpc-service-reactive-transcoding | 50054 | x | 50054 |
| eureka-discovery | x | 8761 | x |
| grpc-service-multi-instances | 55555 | x | 55555 |
| grpc-client-service-multi-instance | 0 | x | 0 |
| grpc-service-multi-instances-arm | 0 | x | 0 |
| grpc-client-service-multi-instance-arm | 0 | x | 0 |
### Installation
Download and compile
```
mvn clean compile
```
Then if you don't find all generated classes, please **update your project** from the specific pom.xml of that module
### Usage
For REST services just use your preferred HTTP tool like [SoapUI](https://www.soapui.org/)
You can use [grpcurl](https://github.com/fullstorydev/grpcurl) to call gRPC services choosing the suitable port
```
- List services
grpcurl --plaintext localhost:50051 list
- Call method
grpcurl --plaintext localhost:50051 net.protobufs.TreeService.ListTrees
grpcurl --plaintext -d '{"kingdom":"arborus","family":"ent","species":"sheep"}' localhost:50051 net.protobufs.TreeService.CreateTree
grpcurl --plaintext -d '{"treeId":"59679", "kingdom":"arborus","family":"ent","species":"shepherd"}' localhost:50051 net.protobufs.TreeService.UpdateTree
grpcurl --plaintext -d '{"treeId":"151526"}' localhost:50051 net.protobufs.TreeService.DeleteTree
```
As the option UnframedRequests is enabled in gRPC services, you can also run [curl](https://curl.se/)
```
curl -v -H "Content-Type: application/json" -d '{}' http://localhost:50052/net.protobufs.TreeService/ListTrees
curl -v -H "Content-Type: application/json" -d '{"treeId":"7952"}' http://localhost:50052/net.protobufs.TreeService/GetTree
curl -v -H "Content-Type: application/json" -d '{"kingdom":"arborus","family":"ent","species":"sheep"}' http://localhost:50052/net.protobufs.TreeService/CreateTree
```
HTTP/JSON to gRPC transcoding is explicitly enabled using .enableHttpJsonTranscoding(). This allows the server to convert HTTP/JSON requests into gRPC requests and vice versa. This option is currently developed in **grpc-server-transcoding** and **grpc-server-reactive-transcoding** modules.
```
curl -v http://localhost:50053/api/v1/trees
curl -v http://localhost:50053/api/v1/trees/465984
curl -v -H "Content-Type: application/json" -d '{"kingdom":"arborus","family":"ent","species":"wild"}' http://localhost:50053/api/v1/trees
curl -v -H "Content-Type: application/json" -d '{"treeId":"611605","kingdom":"arborus","family":"ent","species":"oak"}' http://localhost:50053/api/v1/trees/611605
curl -v -X "DELETE" http://localhost:50053/api/v1/treess/339919
```
It is possible to use a browser to call a service using the documentation feature and the correct port shown in the Components section
```
http://localhost:8091/internal/docs
```
There is a ready Eureka server necessary to check the compatibility with discovery services. The microservice **grpc-service-multi-instances** registers itself on Eureka and sends the gRPC number port. On the other hand, **grpc-client-service-multi-instance** exposes its endpoint but it doesn's have its own database, instead it uses a gRPC stub client to call the methods in grpc-service-multi-instances. Before doing so, it looks up the suitable hostname and port on the eureka-discovery microservice. So if you want to test this proof of concept (PoC), you should run the three components and call the port of grpc-client-service-multi-instance. In this case, It is used the dependency eureka client from Spring framework.
Armeria has its own eureka dependecy, so I have created the same test environment but using this dependency. The microservicies are **grpc-service-multi-instances-arm** and **grpc-client-service-multi-instance-arm**. You could use the same Eureka server to check both of them.
---
[](https://www.java.com/es/)
[](https://https://maven.apache.org/)
[](https://spring.io)
[](https://github.com)
[](https://https://eclipse.org/)
[](https://www.java.com/es/)
[](https://choosealicense.com/licenses/gpl-3.0/)