I have a question regarding the Ask pattern in Akka.
I am calling an actor using the ask pattern from my application. My application is a normal class (not an actor itself):
(actor1Ref ? msg) mapTo[ResponseMsg]
However the actor which is called above calls a second actor like:
secondActor ! msg(sender)
and it's the second actor which returns the actual response like:
originalSender ! responseMsg
So basically there is an indirection involved and when Actor1 calls Actor2 it uses !
.
I tested the code and it works. But I am not sure if the above is the right way of writing this code.
So should I always use ?
between the actor1 and actor2 calls and try to pipeTo
the results? Or is it OK for me to use !
between intermediate calls and when I want to return to the original caller, just send a message to the reference I pass around?