Skip to content

Commit 7ac33ea

Browse files
authored
Add gRPC server sample with Spring Integration
* Add gRPC server sample with Spring Integration Introduce a new basic sample demonstrating the GrpcInboundGateway. This provides users with a reference implementation for handling both unary and server streaming gRPC requests using Spring Boot. - Add grpc-server module with protobuf definitions - Configure GrpcInboundGateway to route by service method - Include tests demonstrating in-process gRPC communication * Add grpc-client using grpc-server in readme - Remove unused properties from application.properties and test - Simplify exclusion for netty in tests - Update javadoc for Applicaition.java to be 3rd person narrative * Update configuration class javadoc - All class javadocs should be 3rd person narrative vs imperative - Add TODO to check exclude for grpc tests
1 parent 78796f7 commit 7ac33ea

File tree

7 files changed

+804
-7
lines changed

7 files changed

+804
-7
lines changed

basic/grpc-server/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
gRPC Server Sample
2+
==================
3+
4+
This example demonstrates the use of **gRPC Inbound Gateway** with Spring Integration.
5+
6+
It uses Java configuration and showcases various gRPC communication patterns including:
7+
8+
* Unary RPC - client sends a single request and receives a single response
9+
* Server streaming RPC - client sends a single request and receives a stream of responses
10+
11+
The sample uses a simple greeting service defined in a Protocol Buffers (protobuf) file that demonstrates how Spring Integration can handle gRPC service implementations through the `GrpcInboundGateway`.
12+
13+
## Running the sample
14+
15+
### Command Line Using Gradle
16+
17+
To start the gRPC server application using Spring Boot run the following:
18+
19+
$ gradlew :grpc-server:bootRun
20+
21+
To test the gRPC server application run the gRPC client sample using Spring Boot run as follows:
22+
23+
$ gradlew :grpc-client:bootRun
24+
25+
You should see output that looks like the following:
26+
27+
```log
28+
2026-03-25T11:10:18.538-04:00 INFO 91646 --- [ main] o.s.i.s.g.c.GrpcClientConfiguration : Single response reply: Hello Jack
29+
2026-03-25T11:10:18.544-04:00 INFO 91646 --- [ault-executor-0] o.s.i.s.g.c.GrpcClientConfiguration : Stream received reply: Hello Stream Jane
30+
2026-03-25T11:10:18.545-04:00 INFO 91646 --- [ault-executor-0] o.s.i.s.g.c.GrpcClientConfiguration : Stream received reply: Hello again!
31+
```
32+
33+
## Testing the sample
34+
35+
The sample includes JUnit tests that demonstrate the various gRPC communication patterns:
36+
37+
$ gradlew :grpc-server:test
38+
39+
### Output
40+
41+
The tests use an in-process gRPC server for testing, configured via `spring.grpc.server.inprocess.name` and `spring.grpc.client.default-channel.address`. When running the unary test, a request with name "Jack" returns:
42+
43+
Hello Jack
44+
45+
When running the server streaming test, a request with name "Jane" returns multiple responses:
46+
47+
Hello Stream Jane
48+
Hello again!

0 commit comments

Comments
 (0)