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: Mucage Mikabar
Country: Nicaragua
Language: English (Spanish)
Genre: History
Published (Last): 23 July 2015
Pages: 93
PDF File Size: 16.2 Mb
ePub File Size: 8.9 Mb
ISBN: 119-3-93937-461-3
Downloads: 69118
Price: Free* [*Free Regsitration Required]
Uploader: Vilabar

The code is provided as a git repository, which you can update any time. Blocking is discouraged though as composab,e will cause performance problems.

A common use case within Akka is to have some computation performed concurrently without needing the extra utility of an Actor AbstractActor. Second and third thenApply methods are executed on Java 8 CompletableFuture instance which executes computational stages on the thread which completed the first stage. Mike has written three books and over fifty articles on software technology.

Note that the pipeTo pipe method used with the? First an example of using Await. It is never executed on a thread of Scala Future because default thenApply breaks the chain and executes on ForkJoinPool.

If the nature of the Future calls invoked by the actor matches or is compatible with the composaboe of that actor e.

For this Future supports onCompleteonSuccess and onFailurerutures which the last two are specializations of the first.

Since it needs to talk to compoosable separate repositoryit takes time to retrieve the list of UserActivity akkka, hence the return type of composalbe is Future CompletableFuture. The completion is delayed: Mike is a hands-on architect who enjoys programming and mentoring. If a Future does contain an Exceptioncalling Await. Similar programs were written in Java and Scala. Both blocking and non-blocking operations can be performed on Akka futures.

  EPISSAGE ALTERNATIF PDF

For these examples PrintResult is defined as follows: Since the result of a Future is created concurrently to the rest of the program, exceptions must be handled differently.

Composable Futures with Akka 2. The map method is fine if we are modifying a single Futurebut if qkka or more Future s are involved map will not allow you to combine them together: The source code for this page can be found here.

Composable Futures with Akka 2.0

Please feel free to edit and contribute a pull request. Other implementations of futures are limited. The real benefit comes when the Future s are created first, and then combining them together.

About Contents Change history No longer available. Future is done using scala-java8-compat library. This is the same result as this example: He has been recognized as a software expert in US federal court. The implementation extends standard Java CompletableFuture.

Futures • Akka Documentation

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.

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:. On the other hand, UserActivityActor queries into a repository to retrieve historical user activities then sends the result to the sender which is UserProxy in this case, with the pipe pattern.

If you need to do conditional propagation, you can use filter: It is very often desirable to be able to combine different Futures with each other, below are some examples on how that can be done in a non-blocking fashion. The sequence and traverse helper methods can make it easier to handle more complex use cases. If the sequence passed to fold is empty, it will return the start-value, in the case above, that will be 0.

  FINANCIAL UNDERTAKING FOR A STUDENT FORM INZ 1014 PDF

Alternatives to blocking are discussed further within this documentation. It is also possible to create an empty Promiseto be filled later, and obtain the corresponding Future:.

Future counterpart in Java; conversion from scala. A chapter is dedicated to java. That is why the asInstanceOf cast to String is used in the above sample. When using non-blocking it is better to use the mapTo method to safely try to cast a Future to an expected type:. Even if the Future has ffutures been completed, when one of these methods is called.

The book provides complete reference information about the classes and methods for working with Akka futures.

There are generally akja ways of getting a reply from an Actor AbstractActor: All async methods without an explicit Executor are performed using the ForkJoinPool. You can also combine two Futures into a new Future that will hold a tuple of zkka two Futures successful results, using the zip operation.

For all other cases, use asynchronous composition as described below.