liveBook · Manning

Tell

As explained in Akka in Action, Second Edition

Tell is an Akka messaging operation that asynchronously sends a message to an actor without waiting for a reply.

Tell sends a message to an Akka actor through its ActorRef. It is commonly written with the bang operator, `!`: `myActorReference ! 1` sends the integer `1` to that actor address. The sender continues rather than waiting for a reply; whether a reply is needed is part of the receiving actor’s protocol. section 2.2.3 section 12.1.3

myActorReference ! 1

Use `!` to send a value matching the actor’s message type. section 2.2.3

An actor’s declared message type constrains tell at compile time. An `ActorSystem[Int]` accepts integer messages, so sending `1` and `10` compiles; attempting to send an `Int` to an actor whose protocol does not accept it fails compilation. This also exposes stale callers when a protocol changes during refactoring. section 2.2.3

Sending to a wallet

A minimal application creates a typed wallet actor and sends two messages: `guardian ! 1` followed by `guardian ! 10`. The actor processes its protocol one message at a time, returning a next behavior for each processed message. Protocols can therefore represent state either through stored values or through different behaviors. section 2.2.3 section 2.6

Tell suits a command whose work can proceed independently of an immediate result. In a betting flow, the bet actor tells a wallet to reserve funds and supplies a response adapter, which turns the wallet’s eventual response into an internal message. This avoids chaining nested questions and their combined timeout decisions. By contrast, a time-sensitive market-state check uses `ask` with an explicit timeout because it requires an answer. section 12.1.3 section 12.1.3

Use tell when designing actor communication:

  • Send only messages included in the target actor’s typed protocol. section 2.2.3
  • Model a reply, if required later, in the protocol through an ActorRef or an adapter rather than blocking the sender. section 12.1.3
  • Prefer it for independent commands; use an answer-oriented interaction when subsequent logic requires a bounded response. section 12.1.3

How Akka in Action, Second Edition covers it

How deep it goes
Defines tell and `!`, demonstrates typed sends, and contrasts command delivery with timed ask-based validation.
Examples
Demonstrates `myActorReference ! 1`, a wallet receiving `1` and `10`, and a bet reserving wallet funds through a response adapter.
What it assumes
Introduces ActorRef addressing and typed messages directly; no prior distributed-failure handling is assumed here.
What you can do after
Apply it via Akka ActorRef to send protocol-conforming commands and model any later response as a message.
How it connects
Connects ActorRef, ActorSystem, actor protocol, behavior, message adapters, and ask-based requests.

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.