COMPOSABLE FUTURES WITH AKKA PDF

“Composable Futures with Akka ” features Java and Scala code examples. The book is available in PDF format. Akka is hot, and Akka. Writing concurrent programs that can run in multiple threads and on multiple cores is crucial but daunting. Composable futures provide a convenient abstraction. Composable Futures With Akka is intended for ‘the rest of us’ – Java and Scala programmers who would like to quickly learn how design.

Author: Dunos Samukinos
Country: Nicaragua
Language: English (Spanish)
Genre: Science
Published (Last): 6 July 2012
Pages: 89
PDF File Size: 18.37 Mb
ePub File Size: 18.57 Mb
ISBN: 384-1-90907-284-6
Downloads: 17462
Price: Free* [*Free Regsitration Required]
Uploader: Domi

Mike has consulted on many legal cases and performed project failure analysis, and has researched and testified in cases involving intellectual property issues such as patent infringement and trade secret misappropriation.

For this Future supports onCompleteonSuccess and onFailureof which the last two are specializations of the first. It is never executed on a thread of Scala Future because default thenApply breaks the chain and executes on ForkJoinPool. Please feel free to edit and contribute a pull request.

Mike has written three books and over fifty articles on software technology.

Java and Scala can both use Akka Futures The uftures implementation bundled in the free, open source Akka stack zkka written in Scala. Both blocking and non-blocking operations can be performed on Akka futures. An overview of futures is provided through code examples. When we finally get the result, it will contain the number Here we wait for the results from the first 2 Actor s before sending that result to the third Actor.

Actors are generally preferred for coordinated or wjth activities. You should either be familiar with programming using Java generics or some Scala before reading this book.

Blocking is discouraged though as it will cause performance problems. The implementation extends standard Java CompletableFuture. Future fallbackTo combines 2 Futures into a new Futureand will hold the successful value of the second Future if the first Future fails. Since it needs to talk to the separate repositoryit takes time to retrieve the list of UserActivityhence the return type of queryHistoricalActivities is Future CompletableFuture.

  COUNT YOUR CHICKENS BEFORE THEY HATCH BY ARINDAM CHAUDHURI PDF

All async methods without an explicit Executor are performed using the ForkJoinPool. Non-async methods When non-async methods are applied on a not yet completed CompletionStagethey are completed by the thread which completes initial CompletionStage: See next section for examples.

Composable futures mean that operations on a future or a collection of futures can be chained together without blocking; for example, transformations such as map can be applied to a composable future.

If a Future does contain an Exceptioncalling Await. You can also use the SBT console to try code snippets interactively. This is fine when dealing with a known amount of Actors, but can grow unwieldy if we have more than a handful.

Here we have 2 actors processing a single message each. It is also possible to create an empty Promiseto be filled later, and obtain the corresponding Future:. The map method is fine if we are modifying a single Futurebut if 2 or more Future s are involved map will not allow you to combine them together:. Composable Futures with Akka 2. If you need to do conditional propagation, you can use filter: Each method of the Akka futures implementation is covered in detail; first introduced with short explanation, then followed by the Java signature and the Scala signature.

Composable Futures with Akka 2.0

When using non-blocking it is better to use the mapTo method to safely try to cast a Future to an expected type: The sequence and traverse helper methods can make it easier to handle more complex use cases. Then we wait for stages to complete so second and third thenApply are executed on completed CompletionStageand stages are executed on the current thread – the thread which called second and third thenApply.

  JIS H3100 PDF

Futures Dependency This section explains using plain Scala Futures but focuses on their interop with Akka Actors, so to follow those examples you will want to depend on: Instead, futues flatMap method should be used: Akkka common use case within Akka is to have some computation performed concurrently without needing the extra utility of compposable Actor AbstractActor. Similar programs were written in Java and Scala.

For these examples PrintResult is defined as follows: Second and third thenApply methods are executed on Java 8 CompletableFuture instance which executes computational stages on the thread which completed the first stage. The Akka and Twitter implementations are much more advanced. When in doubt, async methods with explicit executor should be used. Akka Futures can also be preset to a value or exception when created. Future counterpart in Java; conversion from scala.

Composable Futures with Akka

Failure containing the ArithmeticExceptionfuturees Future would have a result of 0. Actions supplied for dependent completions of non-async methods may be performed by the thread that completes the current CompletableFutureor by any other caller of a completion method.

What are composable futures? Target Audience Composable Futures with Akka 2.

Futures • Akka Documentation

After adding any additional computation stage to CompletionStage returned by scala-java8-compat e. Alternatives to blocking are discussed further within this documentation.

See also Java 8 Compatibility for Java compatibility.