6

Previously i was using Java Future object and Await.result to fetch the response from an Akka actor. This allowed me to create a bridge between Java 6 code base and Akka.

Disadvantages: Threads blocking during long running tasks

I've moved to Java 8 and was looking at making use of non-blocking support to replace the Await.Result with a callback. In theory this will work well. However i notice in latest version of Typesafe HelloAkka tutorial with Java 8 that Akka Inbox is used to handle response rather than Future;

  • Is Inbox use preferred option over Future?
  • When would Future (or Completable Future) be a better option?
cdugga
  • 3,849
  • 17
  • 81
  • 127
  • 1
    Please see ["Should questions include “tags” in their titles?"](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles), where the consensus is "no, they should not"! –  Jun 02 '15 at 15:08

2 Answers2

0

Both responses in this Stackoverflow post added context that may answer your question. Inbox (to my knowledge) is simply an alternative to using futures and calling other actors, instead you are allow other actors to interrogate your inbox (actor like object) from the outside...see this. Also, take a look at the "Cameo" patter by Jamie Allen. I posted a crude example on this Stackoverflow post.

Community
  • 1
  • 1
scarpacci
  • 8,957
  • 16
  • 79
  • 144
0

if you want make a bridge with outside world, how are you intend to use inbox?? I guess all you have is a ref to actor.

take under consideration things like

  • how long can you wait for reply
  • replay can never come back - how you react to that
  • read about circuit breakers which guards your client code with possible errors with services (here akka system)

I would chose java's CompletableFuture as interface and translate akka's futures after ask or tell operation.

kamiseq
  • 593
  • 4
  • 17