Search in sources :

Example 1 with AskIntRequest

use of im.actor.runtime.actors.ask.AskIntRequest in project actor-platform by actorapp.

the class AskcableActor method onReceive.

@Override
public void onReceive(Object message) {
    if (message instanceof AskIntRequest) {
        AskIntRequest askRequest = (AskIntRequest) message;
        try {
            Promise p = onAsk(askRequest.getMessage());
            if (p == null) {
                // Just ignore. We assume that message is stashed
                return;
            }
            p.pipeTo(askRequest.getFuture());
        } catch (Exception e) {
            e.printStackTrace();
            askRequest.getFuture().tryError(e);
        }
    } else {
        super.onReceive(message);
    }
}
Also used : Promise(im.actor.runtime.promise.Promise) AskIntRequest(im.actor.runtime.actors.ask.AskIntRequest)

Aggregations

AskIntRequest (im.actor.runtime.actors.ask.AskIntRequest)1 Promise (im.actor.runtime.promise.Promise)1