Chiunque abbia qualche esempio o idea che usi gRPC insieme a Spring Boot?Utilizzo di Spring Boot insieme a gRPC e Protobuf
risposta
Se è ancora rilevante per te, ho creato il boot-boot-start GRPC here.
grpc-primavera-boot-starter auto-configura e gestisce il server gRPC embedded con @ GRpcService-abilitato fagioli.
L'esempio più semplice:
@GRpcService(grpcServiceOuterClass = GreeterGrpc.class)
public static class GreeterService implements GreeterGrpc.Greeter {
@Override
public void sayHello(GreeterOuterClass.HelloRequest request, StreamObserver<GreeterOuterClass.HelloReply> responseObserver) {
// omitted
}
}
C'è anche un esempio di come integrare il dispositivo d'avviamento con Eureka nel file README del progetto.
A partire da https://spring.io/blog/2015/03/22/using-google-protocol-buffers-with-spring-mvc-based-rest-services, quindi
un'occhiata a SPR-13589 ProtobufHttpMessageConverter support for protobuf 3.0.0-beta4 e legati SPR-13203 HttpMessageConverter based on Protostuff library
Questo è qualche supporto per proto3 è in arrivo nella primavera 5. Come è in fase di sviluppo uno è incoraggiato a votare ed aumentare quello che è importante per il loro progetto.
https://github.com/WThamira/gRpc-spring-boot-example è un esempio corretto per quel caso penso – wthamira
https://github.com/yidongnan/grpc-spring-boot-starter
In Server
@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();
}
}
Nel client
@GrpcClient("gRPC server name")
private Channel serverChannel;
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(serverChannel);
HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName(name).build());
Qui io uso gRpc e eureka alla comunicazione. Questo progetto basato su Spring-boot
https://github.com/WThamira/grpc-spring-boot
inoltre Canuse registrarsi come console anche. completo esempio in questo repo
https://github.com/WThamira/gRpc-spring-boot-example
questo Maven dipendenza aiuto per 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>
e hanno bisogno di spettacolo plug-in sotto
<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. Utilizzo di Spring @Scheduled e @Async insieme
- 2. Utilizzo di Spring JUnit4 e JMock insieme
- 3. Spring Boot e FreeMarker
- 4. Spring Boot: Hibernate e Flyway Boot Order
- 5. Configurazione Spring-Boot e Spring-Security
- 6. Utilizzo di protobuf e POCO in C++
- 7. Integrazione Flyway e Spring Boot
- 8. Spring Boot: utilizzo di un servizio @Service in Quartz
- 9. Spring Boot + Spring swagger error
- 10. Utilizzo delle classi Protobuf rispetto a un framework/strato di mappatura in Java
- 11. Escludi application.properties durante la generazione di war utilizzando spring boot e spring-boot-maven-plugin
- 12. Test di Spring asyncResult() e jsonPath() insieme
- 13. spring-boot-starter-tomcat vs spring-boot-starter-web
- 14. Spring boot - configure EntityManager
- 15. Spring Boot - nesting ConfigurationProperties
- 16. Spring Boot JSP 404
- 17. Spring Boot e OAuth2, WebSecurityConfigurerAdapter vs ResourceServerConfigurerAdapter
- 18. Spring Boot Autowired null
- 19. Spring Boot aggiungere HTML e JavaScript
- 20. Spring Boot devtools IntelliJ
- 21. Spring Boot offfuscator
- 22. Utilizzo di mustache.js insieme a node.js?
- 23. Spring Boot con MongoTemplate
- 24. spring boot dependency injection
- 25. Spring boot + Groovy + logback.groovy
- 26. Utilizzo di Lucene Evidenziatore insieme a MultiFieldQueryParser
- 27. Le proprietà della riga di comando spring-boot sono disponibili quando si utilizza spring-boot: run?
- 28. PreAuthorize e Custom AuthenticationFilter with Spring boot
- 29. Configurazione Camel e Activemq con Spring Boot
- 30. Spring Boot Configurazione Elasticsearch
https://spring.io/blog/2015/03/22/using-google-protocol-buffer-with-spring-mvc-based-rest-services è probabilmente una buona lettura. –
Vero, l'ho già trovato. Ma mi piacerebbe sapere se qualcuno ha legato questo con le definizioni del servizio di protobuf pure? – Markus
Anche cercare un esempio –