On June 2, Friday at 10.30 am is a lecture by Trayan Iliev from IPT with a theme Non-blocking Asynchronous Stream Processing using CompletableFuture and Flow in Java 9.
Stream based data / event / message processing becomes preferred way of achieving interoperability and real-time communication in distributed SOA / microservice / database architectures. Beside lambdas, Java 8 introduced two new APIs explicitly dealing with stream data processing:
- Stream – which is PULL-based and easily parallelizable;
- CompletableFuture / CompletionStage – which allow composition of PUSH-based, non-blocking, asynchronous data processing pipelines.
In terms of Functional Reactive Programming (FRP) they implement two basic types of event streams:
- cold event streams – pull-based, computed lazily whenever there is a demand;
- hot event streams – push-based, non-blocking asynchronous event processing in real time, more complex concurrency and timing requirements (buffering, throttling, scheduling etc.).
Java 9 will provide further support for stream-based data-processing by extending the CompletableFuture with additional functionality – support for delays and timeouts, better support for subclassing, and new utility methods. More, Java 9 provides new java.util.concurrent.Flow API implementing Reactive Streams specification that enables reactive programming and interoperability with libraries like Reactor, RxJava, RabbitMQ, Vert.x, Ratpack, and Akka.
The presentation will discuss the novelties in Java 8 and Java 9 supporting stream data processing, describing the APIs, models and practical details of asynchronous pipeline implementation, error handling, multithreaded execution, dealing with special threads like GUI thread, asyncronous REST service implementation and testing, interoperability with existing libraries and platforms.
There will be provided examples using:
- Completable Future and Flow with JAX-RS 2.0 AsyncResponse
- unit-testing the async REST service method implementations
- CDI 2.0 asynchronous observers (fireAsync / @ObservesAsync)
- RabbitMQ, Reactor and RxJava integrations.