40. #JCConfTaiwan 2017
Reactor Core Features
? Flux, an asynchronous sequence of 0-n items
? Mono, an asynchronous 0-1 result
? Simple ways to create a Flux/Mono and to
subscribe to it
? Programmatically creating a sequence
? Schedulers
? Handling Errors
? Processor
54. #JCConfTaiwan 2017
Scheduler Threading
? Schedulers.immediate()?
current thread
? Schedulers.single()?
single, reusable thread
? Schedulers.elastic()?
elastic thread pool
? Schedulers.parallel()?
fixed pool of workers(CPU cores)
?Schedulers.fromExecutorService(ExecutorService)
55. #JCConfTaiwan 2017
Scheduler Threading (ex: Flux)
Ref: https://stackoverflow.com/a/41941592
Flux.just("a", "b", "c")
.doOnNext(v -> System.out.println("before publishOn: " + Thread.currentThread().getName()))
.publishOn(Schedulers.elastic())
.doOnNext(v -> System.out.println("after publishOn: " + Thread.currentThread().getName()))
.subscribeOn(Schedulers.parallel())
.subscribe(v -> System.out.println("received " + v + " on " + Thread.currentThread().getName()));
before publishOn: parallel-1
before publishOn: parallel-1
before publishOn: parallel-1
after publishOn: elastic-2
received a on elastic-2
after publishOn: elastic-2
received b on elastic-2
after publishOn: elastic-2
received c on elastic-2
Output: