Akka gRPC provides support for building streaming gRPC servers and clients on top of Akka Streams and Akka Http.
mvn compile dependency:properties exec:exec@server
7. Start the client for maven project
mvn compile dependency:properties exec:exec@client
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.knoldus.helloworld";
option java_outer_classname = "HelloWorldKnoldus";
// The greeting service definition.
service GreeterService {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
After compiling .proto file , the code will be generated
First, the GreeterServer main class creates an akka.actor.ActorSystem, a container in which Actors, Akka Streams and Akka HTTP run. Next, it defines a function from HttpRequest to Future[HttpResponse] using the GreeterServiceImpl. This function handles gRPC requests in the HTTP/2 with TLS server that is bound to port 8080 in this example.
#akka #akka-http #akka-streams #grpc #scala