Skip to content

Add gRPC server sample with Spring Integration#382

Merged
artembilan merged 3 commits intospring-projects:mainfrom
cppwfs:SIS-grpc-server
Mar 25, 2026
Merged

Add gRPC server sample with Spring Integration#382
artembilan merged 3 commits intospring-projects:mainfrom
cppwfs:SIS-grpc-server

Conversation

@cppwfs
Copy link
Contributor

@cppwfs cppwfs commented Mar 25, 2026

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

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
@cppwfs cppwfs requested a review from artembilan March 25, 2026 13:16
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.

Pretty cool!

I don't have too many concerns on what you have done so far.

Thank you!

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

Choose a reason for hiding this comment

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

Not related to your work here, but nice to have eventually.
I believe there is a feature on start.spring.io when you chose Spring Integration and some other protocol-specific, e.g. JMS Starter, Spring for Apache Kafka, RabbitMQ starter etc., then respective Spring Integration module is added to dependencies.
For example:
image
And this is a set of dependencies generated from there:

dependencies {
  implementation("org.springframework.boot:spring-boot-starter-integration")
  implementation("org.springframework.boot:spring-boot-starter-webservices")
  implementation("org.springframework.integration:spring-integration-ws")
  testImplementation("org.springframework.boot:spring-boot-starter-webservices-test")
  testImplementation("org.springframework.integration:spring-integration-test")
  testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

So, I think we should raise an improvement request to the https://github.com/spring-io/initializr to include spring-integration-grpc when this or that gRPC starter is chosen together with Spring Integration.

- Remove unused properties from application.properties and test
- Simplify exclusion for netty in tests
- Update javadoc for Applicaition.java to be 3rd person narrative
import org.springframework.messaging.Message;

/**
* Configure {@link org.springframework.integration.grpc.inbound.GrpcInboundGateway}.
Copy link
Member

Choose a reason for hiding this comment

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

Right.
And why this class Javadoc is still imperative?
Looks like we don't need that FQCN for the GrpcInboundGateway: we have it imported and we use it in the following code.

build.gradle Outdated
configurations {
testRuntimeOnly.exclude group: 'io.grpc', module: 'grpc-netty'
testImplementation ('org.springframework.boot:spring-boot-starter-grpc-test') {
exclude group: 'io.grpc', module: 'grpc-netty'
Copy link
Member

Choose a reason for hiding this comment

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

This is cool!
Do we have any story on Spring Boot side to avoid this but control the test behavior via properties?
Or maybe some dedicated to in-process dependency...

- All class javadocs should be 3rd person narrative vs imperative
- Add TODO to check exclude for grpc tests
@artembilan artembilan merged commit 7ac33ea into spring-projects:main Mar 25, 2026
2 checks passed
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.

2 participants