mardi 25 août 2015

akka patterns.ask implementation details

We have a use case where we have a set up like following Master type of Actor, Worker type of Actor. The master receives work request for an input and uses workers to orchestrate and generate result. There is a plan java class client.java. This creates a new instance of master and sends work to it. This client uses - Patterns.ask to get future pointer 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 temperory actor will get created. But, when I invoke and try to print the hashCode of the sender inside master, seemed same actor every time.

I have following concerns 1. How does 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? 2. How does it guarntee that Future pointers are filled with relevent 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 FutureX get Y and FutureY gets X?

Aucun commentaire:

Enregistrer un commentaire