liveBook · Manning

Manager actor

As explained in Akka in Action, Second Edition

A manager actor splits incoming work, delegates pieces to worker actors, and receives their completion notifications.

A manager actor coordinates distributed work: it receives a collection of tasks, splits the work, creates or selects worker actors, delegates each piece, and tracks completion. In the text-parsing example, a guardian sends text to the manager, which creates one worker per text and sends each worker a parsing request. section 3.1 section 3.0

A manager actor typically performs these steps:

  • Receives a delegation message containing the work, such as a list of texts. section 3.1.1
  • Creates a worker for each task and sends the worker a command to process it. section 3.2.2
  • Adapts worker responses into messages that belong to the manager’s protocol. section 3.1.3
  • Receives success or failure reports and records the completed task. section 3.2.2

The manager belongs to an actor hierarchy. A guardian creates it with context.spawn and sends it a Delegate message using tell (!). The manager then creates workers beneath itself, preserving the parent-child structure that makes delegation straightforward. section 3.1.2 section 3.0

Worker replies require an adapter because each actor understands its own protocol. The manager declares an adapter message and an adapter function, translating the worker’s response before handling it as a manager report. section 3.1.3

Parsing two texts

A guardian starts the manager with “-one-” and “--two--”. The manager sends each text to a separate worker. Runtime output shows both workers producing “one” and “two”, followed by manager messages confirming that both texts finished. section 3.1.1 section 3.1.2

Figure 3.2 Direction of messages between the manager and the workers
CH03_F02_Abraham2

Use the message-flow diagram to follow delegation from the manager to workers and completion notifications back to the manager. section 3.1

How Akka in Action, Second Edition covers it

How deep it goes
Explains spawning, delegation, response adaptation, and success or failure reporting, but stops short of external endpoints.
Examples
Uses a text parser that assigns “-one-” and “--two--” to workers and logs parsed results and completion.
What it assumes
Assumes familiarity with ActorSystem and introduces parent-child hierarchy, spawning, actor protocols, and adapters through implementation.
What you can do after
Build a typed Akka actor hierarchy that delegates tasks to workers and handles adapted completion reports.
How it connects
Connects actor hierarchy, guardian actors, worker actors, actor protocols, message adapters, and ActorSystem.

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.