O'Reilly logo

Learning Scala Programming by Vikash Sharma

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The tell versus ask versus forward method

We use one of these three approaches to transmit messages from one actor to another. As we've already established, tell transmits messages and does not wait for the response; this way, we ensure at most once delivery. We can also use the ask method in cases where we expect our called actors to respond back with some messages of the response type. There might be scenarios where you want to forward a message of a particular type with the same actor reference (ActorRef) to another Actor. For this purpose, we can use the forward method:

class AnotherActor extends Actor { override def receive = { case ShowFootballPlayersRequest(url) => { val playersInfoSource = Source.fromFile(url) val players = asPlayers(bufferedSourceToList(playersInfoSource)) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required