I am trying to figure out, how the ask pattern works. In the documentation, it says:
Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.
The interaction has a timeout (to avoid a resource leak). If the timeout hits without any response it will be passed as a Failure(java.util.concurrent.TimeoutException) to the mapResponse function (this is the only "normal" way a Failure is passed to the function).
For other messaging patterns with other actors, see ActorContext#messageAdapter.
This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.
Could someone please provide an example to get a better understanding of ask pattern.