liveBook · Manning

Akka gRPC

As explained in Akka in Action, Second Edition

Akka gRPC is an Akka library that generates and supports gRPC clients and servers for Scala and Java applications.

Akka gRPC exposes an ActorSystem through gRPC ports, letting external applications call Akka-backed services over HTTP/2. It supports both generated clients and servers, with Protocol Buffers defining the service boundary. section 11.0 section 11.2

A typical Akka gRPC integration follows these steps:

  • Add and enable the Akka gRPC sbt plugin, together with Akka HTTP, Akka Streams, service discovery, and HTTP/2 support. section 11.2.3
  • Place a .proto file under src/main/proto and define messages, package options, and RPC methods such as ContainerService.AddCargo. section 11.2.3
  • Compile the project to generate Scala message classes, a client, and a server trait with protobuf marshallers. section 11.2.3 section 11.3
  • Extend the generated server, bind it to the application, and forward requests to actors with ask or tell. section 11.3

Container service

A unary AddCargo RPC accepts a Cargo message containing kind and size, then returns AddedCargo with an ok Boolean. After starting the service, grpcurl can add a bigbag and a sack, then call GetCargos and receive both cargo records. section 11.2.3 section 11.2.7

Betting-house ports

A betting application can use gRPC ports for market and bet updates when order guarantees matter. A gRPC stream provides that behavior, while wallet access can use Akka HTTP; reflection exposes available calls. section 12.2

How Akka in Action, Second Edition covers it

How deep it goes
Explains plugin setup, protobuf definitions, generated artifacts, server binding, actor forwarding, and runnable calls.
Examples
Uses a ContainerService with AddCargo and GetCargos, grpcurl requests, and betting-house market and bet ports.
What it assumes
Assumes an Akka project and sbt while teaching protobuf service definitions and generated Akka integrations.
What you can do after
Operate external gRPC clients and servers that exchange protobuf messages with actors.
How it connects
Connects Protocol Buffers, RPC, Akka HTTP, Akka Streams, HTTP/2, actors, and ActorSystem integration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.