“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: Vuzuru Zulkirr
Country: Cayman Islands
Language: English (Spanish)
Genre: Photos
Published (Last): 10 April 2015
Pages: 114
PDF File Size: 9.10 Mb
ePub File Size: 20.34 Mb
ISBN: 449-7-40827-858-3
Downloads: 63171
Price: Free* [*Free Regsitration Required]
Uploader: Juramar

Composable Futures with Akka 2.0

Even if the Future has already been completed, when one of these methods is called. If the nature of the Future calls invoked by the actor matches or is compatible with the activities of that actor e. When using non-blocking it wih better to use the mapTo method to safely try to cast a Future to an expected type:.

Sometimes you just want to listen to a Future being completed, and react to that not by creating a new Futurebut by side-effecting. Instead of waiting for this f1 to complete, we apply our function that calculates the ak,a of the string using the map method. The Akka and Twitter implementations are much more advanced.

Non-async methods When non-async methods are applied on a not yet completed CompletionStagecomposahle are completed by the thread which completes initial CompletionStage: If you know Java and are learning Scala, comparing the two programs will be instructive.

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

  APEXI VAFC MANUAL PDF

Target Audience Composable Futures with Akka 2. Akka futures integrate easily with existing software projects. Java 8 CompletableFuture creates a new instance of CompletableFuture for any cmposable stage, which means scala-java8-compat implementation is not used after the first mapping method.

When our original Futuref1completes, it will also apply our function and complete the second Future with its result.

The real benefit comes when the Future s are created first, and then combining them together. Since the result of a Future is xkka concurrently to the rest of the program, exceptions must be handled differently.

Future which has async methods only, CompletionStage has async and non-async methods. Practical code examples are used to teach concepts, backed up by ‘just enough’ theory. Since callbacks are executed in any order and potentially in parallel, it can be tricky at the times when you need sequential ordering of operations. The futures implementation provided by Akka 1.

In this example we are joining two strings together within a Future. You should either be familiar with programming using Java generics or some Scala before reading this book. Found an error in this documentation? Now compare that to this example:. You can also use the recoverWith method, which has the same relationship to recover as flatMap has to mapand is use like this:. Instead, the flatMap method should be used:.

The futures implementation bundled in the free, open source Akka stack is written in Scala. Actors are generally preferred alka coordinated or stateful activities.

Handling Exception s will be discussed further within this documentation. When non-async methods are applied on a not yet completed CompletionStagethey are completed by the thread which completes initial CompletionStage:.

  CAUSES OF MFECANE PDF

Mike Slinn – Connoisseur of Technology: Composable Futures with Akka

You can also use the SBT console to try code snippets interactively. The source code for this page can be found here. If the sequence passed to fold is empty, it will return the start-value, in the case above, that will be 0. Please feel free to edit and contribute a pull request. Future fallbackTo combines 2 Futures into a new Futureand will hold the successful value akkz the second Future if the first Future fails.

Akka futures are being subsumed into Scala 2. When in doubt, async methods with explicit executor should be used. In this example, if the actor replied with a akka. To wait for futres retrieve the actual result the simplest method is:. Future counterpart in Java; conversion from scala. After adding any additional computation stage to CompletionStage returned by scala-java8-compat e.

In the above code the block passed to Future will be executed by the default Dispatcherwith the return value of the block used to complete the Future in this case, the result would be the string: Mike Slinn is a principal at Micronautics Research Corp- orationa contract software development firm that focuses on cutting-edge enterprise software technology.