liveBook · Manning

Routee

As explained in Akka in Action, Second Edition

A routee is an actor that a router can select as the destination for a message.

A routee is an actor a router can choose as the destination for a message. Routees let independent work run in parallel: a camera can distribute photo batches among photo processors, while other routers can choose destinations from message content or router state. section 6.2 section 6.3

A routing strategy selects the routee. Round-robin gives each routee a turn; random selects one randomly; consistent hashing deterministically selects one from a message and remains useful as routees change; broadcasting sends qualifying messages to every matching routee. section 6.3 section 6.5

Table 6.1 Router logic options (view table figure)

Logic

Description

RoundRobinRouting

The first received message goes to the first routee, the next message goes to the second routee, and so on. When all routees have received a message, everything starts again from the beginning.

RandomRouting

Each received message goes to a randomly selected routee.

ConsistentHashing

A consistent hashing is applied to the message to select a routee. This algorithm is especially useful for distributing the work evenly among routees whose number may change over time.

withBroadcastPredicate

A message is sent to all routees that satisfy a predicate function T => Boolean, where T is the type of message sent.

Compare the built-in strategies by how they select one routee or fan a message out to several routees. section 6.3

Routee ownership distinguishes the two built-in router forms. A pool router creates and manages its routees, making it suitable when they exist only inside the router’s domain. A group router discovers routees created elsewhere through the receptionist and a service key, allowing their lifecycle and placement to remain under external control. section 6.3 section 6.3.1 section 6.3.3

Figure 6.5 Actor hierarchies of pool and group routers
CH06_F05_Abraham2

See why pool routees are children of their router, whereas group routees may belong to other actors. section 6.3

Pool routees for simple parallel work

Define a pool size and routee behavior, then spawn the resulting router as an ActorRef and send it messages. The router forwards each message according to its strategy; a pool uses round-robin unless configured otherwise. Give routees a restart strategy: a failed routee stops by default, reducing capacity, and a message can reach deadLetters during the interval before the router learns that a child stopped. section 6.3.1 section 6.3.2

Group routees discovered for photo processing

Register independently created photo processors under a ServiceKey, then create a group router with that key. The router cannot deliver a photo URL until at least one processor is registered. Choosing round-robin gives registered processors a fair share of incoming photos. section 6.3.3 section 6.5

Choose a pool when the router should own simple workers. Choose a group when workers must be created, located, or supervised elsewhere. For exceptional messages, use a broadcast predicate so only messages meeting the condition reach every routee, such as a serious highway violation sent to all patrol officers. section 6.3.1 section 6.3.2 section 6.3.3

How Akka in Action, Second Edition covers it

How deep it goes
Explains routee selection, pool and group ownership, discovery, strategies, and failure effects without detailing router internals.
Examples
Uses camera-to-photo-processor distribution and broadcasting serious highway violations to patrol officers.
What you can do after
Apply it via Akka built-in pool or group routers and select round-robin, random, hashing, or broadcast delivery.
How it connects
Connects routees with routers, routing strategies, pool routers, group routers, the receptionist, ServiceKey, and deadLetters.

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.