I am creating a directive for Akka HTTP using the javadsl that performs an
ask on an actor and then returns the resulting object in a type-friendly
way that other directives and route handlers can process easily.
For example:
public CompletionStage<MyClassType> askActor(String actorPath, Object
message, Timeout timeout) {
return extractActorSystem( actorSystem -> {
ActorRef actor = actorSystem.actorFor(actorPath);
CompletionStage<Object> result = PatternsCS.ask(actor, message,
timeout);
return (CompletionStage<MyClassType>) result;
});
}
The return doesn't work because I can't case from Object to MyClassType.
I've looked for a mapTo function in CompletionStage but couldn't find
anything, nor can I seem to find anything that works. I did try using the
Scala Future (using Patterns.ask instead) but ran into similar problems
extracting the type out. I'm sure the solution is quite simple but I can't
seem to crack this one.
Thanks in advance.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.