Context.ask semantics

1.) Is the code in the last parameter of context.ask (the part where you match against Success and Failure) executed as part of the main message processing thread, or is it part of some future callback.

2.) Also I’ve seen in some places where people say that context.ask is synchronous?? That is not true right? The actor does continue processing other messages while the ask is processing. Just want someone to confirm I’m not crazy here.

Thanks!

The typed context.ask mapping is done on the actor thread just before processing the final message so it is safe to look at actor state or use logging for example from the mapping function, I think however, it is cleanest to not do that and just provide a pure function for the transformation and put such logic in the receive handling of the transformed message.

Context.ask is not synchronous, any number of messages could be processed between asking and seeing the transformed response.

1 Like