Reactive and Asynchronous Java


Reactive and Asynchronous applications are growing in popularity, but what is the best way to build them? This course teaches you how to apply the latest concurrency techniques to develop state of the art Java applications. With the rise of Microservices and Service Oriented Architectures, asynchronous concurrency is now critical to day-to-day Java development.

We start off by reviewing the differences between asynchronous and synchronous programming. You then build upon this theory by refactoring a project using different modern concurrency techniques including promises using Java 8’s CompletableFuture, actors using Akka and reactive streams using RxJava. You’ll learn the good, the bad and the ugly between these approaches in terms of compositionality, testability and simplicity.


Course contents

Day 1
Asynchronous vs Synchronous Programming
  • Servlets
  • Asynchronous Servlets (3.0) and Spring
  • Why use asynchronous communications?
  • Solving the C10K Problem and the Microservices Performance problem
  • Timeouts

Approaches to Concurrency
  • The Reactive Manifesto and Functional Reactive Programming
  • Models of Concurrency: Event Based, Promises, The Actor Model, Reactive Streams
  • The full stack - from application right down to the OS

Promises using CompletableFutures
  • What is a Promise?
  • Motivation
  • ExecutorService
  • Creation patterns
  • Composition patterns
  • Exception handling
  • Sequence patterns
Day 2
The Actor Model with Akka
  • What is the Actor model?
  • Why and when would you use actors?
  • Using Akka
  • Testing actors
  • Recovering from exceptions
  • Integration patterns

Reactive Streams with RxJava
  • Introducing Reactive Streams
  • Connecting Reactive streams to databases and web sockets
  • Pull vs. Push models
  • Using RxJava
  • Java 9 Flow API
  • Alternative Reactive Stream Implementations
  • Threading and Back Pressure