In a Reactive System, one component asks or delegates its computation to another component by sending a Message and continues its further steps in an asynchronous way. Once the other component finishes that computation, it will send a response to the original component.
In simple words, one component delegates its request and asks another component to serve that request.
For instance, Akka Toolkit has implemented this Ask pattern as akka.pattern.ask. Like Tell, it also has a function ask and has an operator—? (Ask operator).
Let's implement an Akka application to demonstrate this Ask operator:
- Develop a Data model, as shown here:
case object GetWeather case class WeatherForecast(city:String, temperature:String)
- Develop the WF (Weather Forecasting) Actor, as shown here:
class WFClient(wfTeller: ActorRef) extends Actor...