Do we need Builder & copy constructor everywhere? • Java’s clone() is almost broken (see EffectiveJava) • Java has no Object.assign() in JavaScript • Some framework expects that data is not immutable (!!??) 10
makes deep nest, lambda is not solution for it • CompletableFuture<T> is better solution, have a try with it • similar with Promise<T> in JavaScript • It works with @Async in Spring Framework 11
and widget 16 load user load post combine data persist combined data load widget render Why we don’t start loading before persisting combined data? why don’t we load user and post in parallel?
thread, • You wait until other threads finish their task, and • You zip (combine) them to start a task in another thread. • You may need to care which thread we run each task (e.g. UI thread) 17
(lambda or method) • Keep tasks stateless, idempotence and thread safe • Prefer CompletableFuture<T> than Callable<T> • Encapsulate state/mutability in each task • disclose immutable data to others 20
run tasks? • How to handle the exception in tasks? • How to make implementation testable? • How to cache, concat, filter, group, retry and throttle data? 22
Akka-streams, RxJava and Project Reactor (ref for diff) • JDK9 Flow could be standard in future • Project Reactor is most flesh and well-integrated with Spring 25
specify the thread to run tasks? • How to handle the exception in tasks? • How to make implementation testable? • How to cache, concat, filter, group, retry and throttle data? 26
to run tasks • Schedulers.parallel() for non-blocking tasks, to use fixed size thread pool. • Schedulers.elastic() for blocking tasks (JDBC etc.), to launch new thread if necessary. 27
specify the thread to run tasks? • How to handle the exception in tasks? • How to make implementation testable? • How to cache, concat, filter, group, retry and throttle data? 32
specify the thread to run tasks? • How to handle the exception in tasks? • How to make implementation testable? • How to cache, concat, filter, group, retry and throttle data? 35
specify the thread to run tasks? • How to handle the exception in tasks? • How to make implementation testable? • How to cache, concat, filter, group, retry and throttle data? 38
for further Subscribers • concat() Subscribers to make single subscriber • filter() source value before emit it (same with Stream API) • groupBy() some key, to make multiple publishers (similar with groupingBy collector) • retry() subscribe when subscribers throw error • for throttling, sampleTimeout() could be help 39
support webflux • Actuator (monitoring) : done • Springfox (Swagger): not yet • We have sample project depending on snapshot • Validation: not yet for functional endpoint (or apply hack like this) 44
My sandbox project: DependJ • CommandLineRunner helps you to touch raw command line parameter • ApplicationRunner helps you to handle command line parameter • You can simplify code to run tasks in parallel 45
reactor-extra provides schedulers for event dispatch thread • like RxJava for Android app, we can use project reactor to separate backend computation and frontend operation 46
focuses on dataflow, and what I explained partially in this slide • Spread sheet like Excel provides reactive feature (Wikipedia) • “=B1+C1” will be updated when B1 and/or C1 is changed 51
can apply it to MSA & distributed service • Project Reactor provides backpressure • Reactive Systems (that can be achieved by Reactive Streams) can make distributed system responsive, elastic, resilient and message driven. 52