Рет қаралды 7,280
Blocking/synchronous programming has been the norm in Java. However this programming model has a major limitation: it requires one thread per concurrent request. This means that the number of requests you can process concurrently cannot exceed the number of threads, which limits scaling. This talk will explore how an asynchronous programming model can be used to avoid this limitation.
After an introduction to asynchronous design, there will be a live coding session where we will build an example service that makes concurrent calls.
We will cover the following tools:
- The Java Future
- New in Java 8: The CompletableFuture
- RxJava Observables
- The async Servlet, Spring and JAX-RS APIs
- The Ratpack Promise
The see the following patterns:
- Merging multiple calls into a single result
- Returning a result when a subset of multiple calls return without blocking waiting for the rest (e.g. saving an audit log without blocking the user request)
- Executing multiple calls and creating a result from the one that returns first
By the end of the session you should be aware of the popular tools you have for non-blocking programming in Java and when and why you should use them.