diff --git a/README.md b/README.md index 4d978fb..815c190 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This project is a simple example of how to use gRPC with Spring Cloud Gateway, w ### Generate protobuf file ```shell - .\gradlew build + gradle build ``` ```shell .\gradlew.bat build @@ -19,7 +19,7 @@ This project is a simple example of how to use gRPC with Spring Cloud Gateway, w ### Run project ```shell - .\gradlew bootRun --parallel + gradle bootRun --parallel ``` ```shell .\gradlew.bat bootRun --parallel diff --git a/gateway-service/src/main/java/com/nduyhai/gateway/GRPCLocalConfiguration.java b/gateway-service/src/main/java/com/nduyhai/gateway/GRPCLocalConfiguration.java index b6a5383..6c3b2e4 100644 --- a/gateway-service/src/main/java/com/nduyhai/gateway/GRPCLocalConfiguration.java +++ b/gateway-service/src/main/java/com/nduyhai/gateway/GRPCLocalConfiguration.java @@ -9,13 +9,14 @@ @Configuration public class GRPCLocalConfiguration { - @Bean - public GrpcSslConfigurer grpcSslConfigurer(HttpClientProperties properties) { - return new GrpcSslConfigurer(properties.getSsl()) { - @Override - public ManagedChannel configureSsl(NettyChannelBuilder builder) { - return builder.usePlaintext().defaultLoadBalancingPolicy("round_robin").build(); - } - }; - } + + @Bean + public GrpcSslConfigurer grpcSslConfigurer(HttpClientProperties properties) { + return new GrpcSslConfigurer(properties.getSsl()) { + @Override + public ManagedChannel configureSsl(NettyChannelBuilder builder) { + return builder.usePlaintext().defaultLoadBalancingPolicy("round_robin").build(); + } + }; + } } \ No newline at end of file diff --git a/gateway-service/src/main/java/com/nduyhai/gateway/GatewayServiceApplication.java b/gateway-service/src/main/java/com/nduyhai/gateway/GatewayServiceApplication.java index 729a018..830ca50 100644 --- a/gateway-service/src/main/java/com/nduyhai/gateway/GatewayServiceApplication.java +++ b/gateway-service/src/main/java/com/nduyhai/gateway/GatewayServiceApplication.java @@ -6,8 +6,8 @@ @SpringBootApplication public class GatewayServiceApplication { - public static void main(String[] args) { - SpringApplication.run(GatewayServiceApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(GatewayServiceApplication.class, args); + } } diff --git a/greeting-service/src/main/java/com/nduyhai/greeting/GreetingService.java b/greeting-service/src/main/java/com/nduyhai/greeting/GreetingService.java index 13ff499..90102c7 100644 --- a/greeting-service/src/main/java/com/nduyhai/greeting/GreetingService.java +++ b/greeting-service/src/main/java/com/nduyhai/greeting/GreetingService.java @@ -11,18 +11,19 @@ @GRpcService @Slf4j public class GreetingService extends GreetingServiceGrpc.GreetingServiceImplBase { - @Override - public void hello(Greeting.HelloRequest request, StreamObserver responseObserver) { - try { - Greeting.HelloResponse response = Greeting.HelloResponse.newBuilder() - .setGreeting("Hello, " + request.getName()) - .build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - log.info("Create user completed"); - } catch (Exception ex) { - responseObserver.onError(ex); - } + @Override + public void hello(Greeting.HelloRequest request, + StreamObserver responseObserver) { + try { + Greeting.HelloResponse response = Greeting.HelloResponse.newBuilder() + .setGreeting("Hello, " + request.getName()).build(); + + responseObserver.onNext(response); + responseObserver.onCompleted(); + log.info("On completed"); + } catch (Exception ex) { + responseObserver.onError(ex); } + } } diff --git a/greeting-service/src/main/java/com/nduyhai/greeting/GreetingServiceApplication.java b/greeting-service/src/main/java/com/nduyhai/greeting/GreetingServiceApplication.java index eca8792..cc931ae 100644 --- a/greeting-service/src/main/java/com/nduyhai/greeting/GreetingServiceApplication.java +++ b/greeting-service/src/main/java/com/nduyhai/greeting/GreetingServiceApplication.java @@ -6,8 +6,8 @@ @SpringBootApplication public class GreetingServiceApplication { - public static void main(String[] args) { - SpringApplication.run(GreetingServiceApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(GreetingServiceApplication.class, args); + } } \ No newline at end of file