Skip to content

Latest commit

 

History

History
86 lines (59 loc) · 2.55 KB

README.md

File metadata and controls

86 lines (59 loc) · 2.55 KB

grpc server with springboot

generated single file from proto file

I put generated file in api folder, since proto fils and generated files should be apis between client and server

option java_package="com.pxample.api";
//option java_multiple_files = true;
option java_outer_classname = "CityScore";

the starter with grpc server

		<dependency>
			<groupId>net.devh</groupId>
			<artifactId>grpc-server-spring-boot-starter</artifactId>
			<version>2.12.0.RELEASE</version>
		</dependency>

@GrpcService

Annotation that marks gRPC services that should be registered with a gRPC server. If spring-boot's auto configuration is used, then the server will be created automatically. This annotation should only be added to implementations of BindableService (GrpcService-ImplBase).

The starter will add service to grpc server automatically.

source folder and target folder

					<protoSourceRoot>
						${basedir}/src/main/resources/proto/
					</protoSourceRoot>
					<outputDirectory>${basedir}/src/main/java/</outputDirectory>
					<clearOutputDirectory>false</clearOutputDirectory>

The false value will not clean the generated folder when compiling the proto files.

Customized grpc exception

@GrpcAdvice
public class CityScoreExceptionHandler {

    @GrpcExceptionHandler(CityScoreException.class)
    public StatusRuntimeException handleValidationError(CityScoreException cause) {
        ...

Ref

gRPC Implementation With Spring Boot

gRPC Error Handling

gRPC-Spring-Boot-Starter Documentation

Status codes and their use in gRPC

grpc server cpp demo

grpc client cpp demo

grpc client with springboot demo

grpc server with springboot demo

grpc client java demo

grpc server java demo

sprintboot with grpc server. Fork from nils

gRPC Java Client App Implementation

grpc sample on github