Chapter 12

  1. What is the meaning of the Behavior[Tpe] definition?

Behavior[Tpe] explicitly specifies that this actor is capable of handling messages that are subtypes of Tpe. By recursion, we can conclude that the returned behavior also will be Behavior[Tpe].

  1. How do you get access to the scheduler in the actor's behavior?

The schedule is accessible via the behavior constructor, Behaviors.withTimers.

  1. Describe possible ways an actor can be stopped.

An actor can be stopped by the parent using the parent's actor context: context.stop(child).

An actor can also stop itself by returning respective behavior: Behaviors.stopped.

An actor can also be stopped if an exception was thrown by the actor's logic and the SupervisorStrategy defined for this actor is stop.

  1. What is the difference between a local and a cluster receptionist?

There are different implementations but there is no noticeable difference for the developer.

  1. What supervision possibilities exist and how are they defined?

There are three supervision strategies: stop, restart, and resume. They are defined by wrapping an actor in supervising behavior using Behaviors.supervise.

  1. Why should stashing be used judiciously?

Current stashing implementation buffers messages in memory and can lead to OutOfMemory or StashOverflowException, depending on the stash size. If messages are unstashed, the actor will not produce other incoming messages until all stashed bits are processed, which might make it unresponsive.

  1. What is a preferred way to test actor logic in isolation?

Synchronous testing using BehaviorTestKit provides better possibilities to test actor logic in isolation.

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

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