Ktoś ma jakieś przykłady lub myśli używając gRPC razem z Spring Boot?Używanie Spring Boot razem z gRPC i Protobuf
Odpowiedz
Jeśli nadal jest to dla ciebie istotne, stworzyłem sprężynę rozruchową gRPC here.
grpc sprężynowym rozruchu rozrusznik auto konfiguruje i uruchamia wbudowany serwer gRPC z @ GRpcService obsługującej fasoli.
Najprostszy przykład:
@GRpcService(grpcServiceOuterClass = GreeterGrpc.class)
public static class GreeterService implements GreeterGrpc.Greeter {
@Override
public void sayHello(GreeterOuterClass.HelloRequest request, StreamObserver<GreeterOuterClass.HelloReply> responseObserver) {
// omitted
}
}
Jest też przykładem, jak zintegrować rozrusznik z Eureka w pliku README projektu.
Począwszy od https://spring.io/blog/2015/03/22/using-google-protocol-buffers-with-spring-mvc-based-rest-services, następnie
przyjrzeć SPR-13589 ProtobufHttpMessageConverter support for protobuf 3.0.0-beta4 i związane SPR-13203 HttpMessageConverter based on Protostuff library
czyli pewne wsparcie dla proto3 nadchodzi wiosną 5. Jak to jest w fazie rozwoju jednej zachęca do głosowania i podnieść to, co jest ważne dla ich projektu.
https://github.com/WThamira/gRpc-spring-boot-example jest poprawnym przykładem dla tego przypadku, myślę, że – wthamira
https://github.com/yidongnan/grpc-spring-boot-starter
W serwerze
@GrpcService(GreeterGrpc.class)
public class GrpcServerService extends GreeterGrpc.GreeterImplBase {
@Override
public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
HelloReply reply = HelloReply.newBuilder().setMessage("Hello =============> " + req.getName()).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
}
klient
@GrpcClient("gRPC server name")
private Channel serverChannel;
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverChannel);
HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());
Tu używam gRpc i eureka do komunikacji. Projekt ten opiera się na wiosennym-boot
https://github.com/WThamira/grpc-spring-boot
dodatkowo canuse zarejestrować się jako konsul również. pełny przykład w tym repo
https://github.com/WThamira/gRpc-spring-boot-example
to Maven zależność pomagają gRpc
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.0.1</version>
</dependency>
i potrzebujesz wtyczki pokaz w poniższej
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<!-- The version of protoc must match protobuf-java. If you don't depend
on protobuf-java directly, you will be transitively depending on the protobuf-java
version that grpc depends on. -->
<protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
- 1. Używanie Spring @Scheduled i @Sync razem
- 2. Spring Boot i FreeMarker
- 3. Spring Boot: Używanie @Service w realizacji kwarcu
- 4. Spring Boot z MongoTemplate
- 5. Jak korzystać z gRPC z Flatbufferami?
- 6. Spring Boot JSP 404
- 7. Spring Boot 1.4.1 i Cassandra 3.x
- 8. Spring Boot AutoConfiguration Order
- 9. Spring Boot devtools IntelliJ
- 10. Spring Boot - nesting ConfigurationProperties
- 11. Używanie MySQL i Mongodb razem
- 12. Spring Boot + Websocket (SockJS)
- 13. Używanie sqldf i RPostgreSQL razem
- 14. Spring Boot Autowired null
- 15. Używanie AVCaptureSession i AVAudioPlayer razem
- 16. Wyrzutnia synchroniczna Spring Boot
- 17. Spring boot + cassandra
- 18. Spring Boot: Hibernate and Flyway boot order
- 19. Spring Boot @EnableScheduling warunkowo
- 20. Spring Boot Application
- 21. Używanie właściwości Maven w application.properties w Spring Boot
- 22. @EnableTransactionManagement w Spring Boot
- 23. Spring Boot i OAuth2, WebSecurityConfigurerAdapter kontra ResourceServerConfigurerAdapter
- 24. Konwertuj istniejącą aplikację Spring na Spring-Boot
- 25. Testowanie Spring asyncResult() i jsonPath() razem
- 26. Spring Boot: Load @Value z pliku YAML
- 27. Jak używać Dozer z Spring Boot?
- 28. Poświadczenia klienta Spring Boot + Oauth2
- 29. Jak działa spring-boot @ConditionalOnClass?
- 30. Spring Boot ignorowanie logback-spring.xml
https://spring.io/blog/2015/03/22/using-google-protocol-buffers-with-spring-mvc-based-rest-services to prawdopodobnie dobra lektura. –
Prawda, już to znalazłem. Ale chciałbym się dowiedzieć, czy ktoś powiązał to z definicjami usług protobuf? – Markus
Poszukuję też przykładu: –