Skip to content

Add gRPC server and client samples with Spring Integration#377

Open
cppwfs wants to merge 1 commit intospring-projects:mainfrom
cppwfs:SIS-add-grpc-samples
Open

Add gRPC server and client samples with Spring Integration#377
cppwfs wants to merge 1 commit intospring-projects:mainfrom
cppwfs:SIS-add-grpc-samples

Conversation

@cppwfs
Copy link
Contributor

@cppwfs cppwfs commented Feb 12, 2026

Implement gRPC examples demonstrating Spring Integration's gRPC support for both server and client scenarios.

Server implementation:

  • Add GrpcInboundGateway with service routing for multiple RPC patterns
  • Implement unary RPC and server streaming streaming methods
  • Configure HelloWorldService with message routing based on service method headers

Client implementation:

  • Add GrpcOutboundGateway for unary and streaming response handling
  • Implement ApplicationRunner beans to demonstrate both communication patterns

Implement gRPC examples demonstrating Spring Integration's
gRPC support for both server and client scenarios.

Server implementation:
- Add `GrpcInboundGateway` with service routing for multiple RPC patterns
- Implement unary RPC and server streaming streaming methods
- Configure HelloWorldService with message routing based on service method headers

Client implementation:
- Add `GrpcOutboundGateway` for unary and streaming response handling
- Implement ApplicationRunner beans to demonstrate both communication patterns
@rishiraj88
Copy link

Looks promising. Thanks.

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also would be great to have tests for these new examples.
This way the samples project would serve a role of smoke tests for core project.
Thanks

springBootVersion=4.1.0-SNAPSHOT
protobufVersion=4.29.4
protobufPluginVersion=0.9.4
grpcVersion=1.78.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not where we keep versions.
See ext block in the build.gradle.
And I guess we don't need protobufPluginVersion variable since it can simply go to the plugin definition itself.


dependencies {
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation "org.springframework.integration:spring-integration-grpc:7.1.0-SNAPSHOT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need explicit SI version here?
More over there is a dedicated variable in the ext block.

api("io.grpc:grpc-stub:$grpcVersion")
implementation("io.grpc:grpc-protobuf:$grpcVersion")
implementation ("io.grpc:grpc-services:$grpcVersion")
implementation("com.google.protobuf:protobuf-java:$protobufVersion")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need these deps if we use org.springframework.grpc:spring-grpc-spring-boot-starter ?

//Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.integration:spring-integration-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need this, then it probably should go to the common deps section for all the projects.


//Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.integration:spring-integration-test'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one has to be in the common deps section.
If that is not the case, we should consider to improve the project.


dependencies {
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation "org.springframework.integration:spring-integration-grpc:7.1.0-SNAPSHOT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fix the server sample, I guess same has to be done for the client one, too.

@@ -0,0 +1 @@
spring.grpc.server.port=9090 No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line in the end of each file.
I believe there supposed to be an option in IntelliJ IDEA.

MessageChannel grpcInputChannelStreamResponse,
FluxMessageChannel grpcStreamOutputChannel) {
//TODO: Need advice, there has to be a better way than what I have below (or is this a bug in the
// GrpcOutboundGateway?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let's debug it together to see what is going on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants