liveBook · Manning

gRPC streaming

As explained in Quarkus in Action

A gRPC stream is a protocol-level sequence through which a gRPC call exchanges multiple messages over time.

gRPC streaming lets one call exchange multiple messages over time instead of pairing one request with one response. It supports server streaming, client streaming, and bidirectional streaming, alongside ordinary unary calls. section 4.8.1

Choose the streaming direction according to which side produces multiple messages:

  • Unary sends one request and returns one response. section 4.8.1
  • Server streaming returns multiple responses for one request. section 4.8.1
  • Client streaming sends multiple requests during one call. section 4.8.1
  • Bidirectional streaming allows both sides to send multiple messages. section 4.8.1

Streaming inventory updates

An inventory service can accept several cars over one connection and return a response for each car. Declare the RPC as `rpc add(stream InsertCarRequest) returns (stream CarResponse) {}`. In Quarkus, represent incoming and outgoing messages with Mutiny `Multi` values. Map each request to a `Car`, persist it, and map that model to a `CarResponse`. Because database I/O is blocking, annotate the method with `@Blocking` rather than running it on the event-loop thread. section 8.4.2

How Quarkus in Action covers it

How deep it goes
Explains stream directions and implements a bidirectional Mutiny pipeline, while deferring detailed client-side streaming code.
Examples
Demonstrates an Inventory service that adds multiple cars and maps each InsertCarRequest to a persisted CarResponse.
What it assumes
Assumes protobuf RPC definitions, Quarkus gRPC support, generated service interfaces, and basic Mutiny Uni usage.
What you can do after
Build bidirectional gRPC endpoints with Quarkus and Mutiny, including persistence-aware request and response pipelines.
How it connects
Connects gRPC streaming with Protocol Buffers, Quarkus, Mutiny Multi, reactive programming, database persistence, and event-loop constraints.

Related concepts

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