Chapter 13

  1. Name two different modes associated with "classic" streams. Why are they problematic?

The two modes are push and pull. Push is problematic in the case of a slow consumer because it can lead to dropped stream elements or memory overflow. Pull is suboptimal in the case of a slow producer because it can lead to blocking or extensive resource consumption.

  1. Why are Reactive Streams considered to work in dynamic pull-push mode?

Reactive Streams introduce the notion of non-blocking back pressure. The consumer reports the demand it has and the producer pushes data in batches according to this demand. When the consumer is faster, the demand is always there so the producer is always pushing data as soon as it is available. If there is a producer which is faster, there is always data available and the consumer just pulls it as soon as it has some demand. The flow automatically switches between these modes.

  1. What are the typical building blocks of Akka Stream's graph?

A flow is a stage with exactly one input and one output. Fan-In has multiple inputs and one output. Fan-Out is the opposite with multiple outputs and one input. BidiFlow represents bi-directional flow with two inputs and two outputs.

  1. How do you convert a graph into a runnable graph?

A graph can be connected into a runnable graph by connecting a source and a sink to it.

  1. What is the main goal of having materialization as a separate explicit step?

Before the materialization step, any graph can be considered to be just a blueprint of the stream and hence can be freely shared and reused.

  1. Describe the effects of applying different supervision strategies.

There are three different supervision strategies.

Stop interrupts the stream in the failed processing stage. The failure propagates downstream and cancellation propagates upstream.

Resume drops the current element and continues streaming.

Restart drops the current element, cleans the internal state of the processing stage (usually by re-creating it), and continues steaming.

  1. Which main abstractions provide Akka Streams TestKit? Why are they useful?

Two main abstractions provided by Akka Streams TestKit are TestSink and TestSource. They allow the control and verification of assumptions about stream flow on different levels, for example, a high messaging level or low reactive-streams level. They also make it possible to use a nice DSL to drive the test and to formulate expectations about the outcomes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.226