We have a use case where we have a set up like following: Master type of Actor and Worker type of Actor.
The master receives work request for an input and uses workers to orchestrate and generate result.
There is a plan to create a Java class named client.java. This creates a new instance of master and sends work to it. This client uses - Patterns.ask to get future pointers and later blocks on it until results are arrived.
Patterns.ask(master, initialMessage, t);
Await.result to get the message
The internal documentation of Patterns.ask says a temporary actor will get created. But, when I invoke and try to print the hashCode of the sender inside master, it seemed same actor every time.
I have following concerns:
- How is concurrent invocations of Patterns.ask managed? Can it happen like a thread after calling, ask gets a future pointer but wrong data is put in it?
- How does it guarantee that Future pointers are filled with relevant responses only and not mixed up with responses from others?
For ex: FutureX = future Expecting X message
FutureY = future Expecting Y message
Can it ever happen that FutureX get Y and FutureY gets X?