liveBook · Manning

Server streaming

As explained in Akka in Action, Second Edition

Server streaming is a remote procedure call pattern in which one client request produces multiple server responses.

Server streaming is an RPC pattern in which one client request produces multiple server responses. Unlike a unary RPC, the response remains a stream for the connection's lifetime, while client-to-server and server-to-client flows are managed separately. HTTP/2 multiplexing allows several connections to share one efficient connection. section 11.2.2

Following a moving car

A LocatorService exposes Follow, accepting an empty request and returning a stream of Location values. Calling it once produces an effectively infinite sequence, such as latitude 1, 2, and 3, followed by one update per second. A client can keep consuming the stream while the car service runs. section 16.3.4

Streaming does not by itself provide recovery when the server disappears. Wrap the generated gRPC client call in a RestartSource, configure backoff and restart limits, and consume the resulting source. After a service failure, the client logs unavailable errors, waits between attempts, and resumes receiving locations when the service returns. section 16.3.4

How Akka in Action, Second Edition covers it

How deep it goes
Defines the RPC shape, demonstrates an infinite response stream, and extends it with restart backoff; it stops short of stream internals.
Examples
Uses a LocatorService, grpcurl output, a one-update-per-second location stream, and a client test that survives service restarts.
What it assumes
Assumes familiarity with RPC and generated gRPC clients while contrasting server streaming with unary calls.
What you can do after
Builds a streaming gRPC endpoint and configures an Akka Streams client to reconnect with bounded exponential backoff.
How it connects
Connects RPC streaming with gRPC, HTTP/2, unary RPC, Akka Streams, generated clients, and RestartSource.

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.