When to choose between using an Incoming or Actor Futures pending a response?

I used to use a Java Future object and Await.result to get a response from an Akka actor. This allowed me to create a bridge between the Java 6 code base and Akka.

Disadvantages : blocking threads during long tasks

I switched to Java 8 and was looking for non-blocking support to replace Await.result callback. Theoretically, this will work well. However, I notice in the latest version of the HelloAkka virtualization tutorial with Java 8 that Akka Inbox is used to process the response, not the future;

  • Is Inbox Preferred For The Future?
  • When will the future (or the full future) become a better option?
+6
source share
2 answers

Both answers in fooobar.com/questions/820583 / ... added a context that can answer your question. Inbox (as far as I know) is just an alternative to using futures and calling other participants, instead you allow other actors to poll your inbox (an object similar to an actor) from the outside ... see this . Also, take a look at the Cameo launched by Jamie Allen. I posted a rough example on this Stackoverflow post.

0
source

If you want to create a bridge with the outside world, how are you going to use your mailbox? I think all you have is an actor to an actor.

consider things like

  • How long can you wait for an answer
  • Repeat can never come back - how do you react to it
  • read about switches that protect your client code with possible errors with services (here akka system)

I would select java CompletableFuture as an interface and translate akka futures after asking or reporting an operation.

0
source

Source: https://habr.com/ru/post/987995/


All Articles