Future in WebApp (Java)

Future in WebApp (Java)

Short description about Future and CompletableFuture


Kengo TODA

July 17, 2016


  1. Future in WebApp Kengo TODA

  2. Agenda • What is Future • What is CompletableFuture •

    Common usage in WebApp
  3. What is Future? • Proxy interface to get result of

    async operation • Similar with JavaScript’s Promise
  4. Ask, and it will be given to you

  5. How to implement method which returns Future instance? • Asynchronous

    Method Invocation (Java EE 6) • Creating Asynchronous Methods (Spring Framework)
  6. What is CompletableFuture • New class from Java8, implements Future

    interface • Similar with ListenableFuture in Guava and Spring Framework
  7. Apply result to Function,

  8. or combine them.

  9. Merit: connect result of Async I/O seamlessly auth add new

    post load timeline START END
  10. None
  11. When we use them? • When call async I/O •

    Datastore • Message Queue • Cache • RESTful API
  12. Example: When we use them? • If you are service

    provider, • Public service API (interface for user) should return CompletableFuture instance if it may use I/O internally. • Then during I/O is running, your user can use current thread for other usage.
  13. Keywords to google • Promise, Future • CompletableFuture • ListenableFuture

    (Guava & Spring Framework) • Function composition