====== Project Reactor ======
* http://projectreactor.io/
* [[reactive_programming:reactive_streams|Reactive Streams]] 구현.
* [[https://projectreactor.io/docs/core/release/reference/#which-operator|Reactor 3 Reference Guide - 어떤 연산자를 사용할 것인가?]]
===== 동기 호출을 비동기로 전환하기(JDBC 등) =====
* ''CompletableFuture'', ''@Async'', 그리고 Reactor가 제공해주는 기능등을 통해 동기 호출을 쓰레드 기반 비동기로 전환할 수 있다.
* [[https://stackoverflow.com/questions/42299455/spring-webflux-and-reading-from-database|reactive programming - Spring webflux and reading from database - Stack Overflow]]
* [[https://projectreactor.io/docs/core/release/reference/#faq.wrap-blocking|Reactor 3 Reference Guide Blocking 호출을 비동기로 전환하기]]
* [[https://dzone.com/articles/spring-5-webflux-and-jdbc-to-block-or-not-to-block|Spring 5 WebFlux and JDBC: To Block or Not to Block - DZone Java]]
* [[https://musigma.blog/2016/11/21/reactor.html|Reactive systems using Reactor]]
* [[java:jpa:springdatajpa|Spring Data JPA]] ''@Aync'' 참조. ''CompletableFuture'' -> ''Mono/Flux'' 전환 가능
Mono blockingWrapper = Mono.fromCallable(() -> {
return /* make a remote synchronous call */
});
blockingWrapper = blockingWrapper.subscribeOn(Schedulers.elastic());
@GetMapping(value = "/v1/measurements")
public Flux getMeasurements() {
return Flux.defer(() -> Flux.fromIterable(repository.findByFromDateGreaterThanEqual(new Date(1486980000L))))
.subscribeOn(Schedulers.elastic());
}
@Configuration
public class SchedulerConfiguration {
private final Integer connectionPoolSize;
public SchedulerConfiguration(@Value("${spring.datasource.maximum-pool-size}") Integer connectionPoolSize) {
this.connectionPoolSize = connectionPoolSize;
}
@Bean
public Scheduler jdbcScheduler() {
return Schedulers.fromExecutor(Executors.newFixedThreadPool(connectionPoolSize));
}
}
@Service
public class AddressService {
private final AddressRepository repository;
private final Scheduler scheduler;
public AddressRouter(AddressRepository repository, @Qualifier("jdbcScheduler") Scheduler scheduler) {
this.repository = repository;
this.scheduler = scheduler;
}
public Mono> findAll() {
return async(() -> repository.findAll());
}
private Mono async(Callable callable) {
return Mono.fromCallable(callable).publishOn(scheduler);
}
}
===== Tuning =====
* [[reactive_programming:block_hound|Block Hound]]
===== 참조 =====
* [[http://wiki.sys4u.co.kr/pages/viewpage.action?pageId=7766994|연습문제로 배워보는 Reactor]]
* [[http://javacan.tistory.com/category/Reactive|최범균님의 Reactive Streams, Reactor 정리]]
* [[http://javacan.tistory.com/492|자바캔(Java Can Do IT) :: 스프링 리액터 시작하기 1 - 리액티브 스트림 Flux Mono Subscriber]]
* [[https://www.javacodegeeks.com/2018/06/spring-reactor-tutorial.html|Spring Reactor Tutorial | Java Code Geeks - 2018]]
* [[https://spring.io/blog/2016/04/19/understanding-reactive-types|Understanding Reactive types]]
* [[https://github.com/reactor/reactive-streams-commons/issues/21|101 Reactive Gems (working title) · Issue #21 · reactor/reactive-streams-commons]]
* [[https://spring.io/blog/2016/03/11/reactor-core-3-0-becomes-a-unified-reactive-foundation-on-java-8|Reactor Core 3.0 becomes a unified Reactive Foundation on Java 8]]
* [[http://tech.kakao.com/2018/05/29/reactor-programming/|사용하면서 알게 된 Reactor, 예제 코드로 살펴보기]]
* [[https://piotrminkowski.wordpress.com/2018/10/22/reactive-programming-with-project-reactor/|Reactive programming with Project Reactor – Piotr's TechBlog]]
* [[https://spring.io/blog/2019/02/06/spring-tips-testing-reactive-code|Spring Tips: Testing Reactive Code]]
* [[https://dzone.com/articles/spring-tips-the-reactor-context-video|Spring Tips: The Reactor Context [Video] - DZone Java]]
* [[https://spring.io/blog/2019/05/29/spring-tips-debugging-reactor-applications|Spring Tips: Debugging Reactor Applications]]
* [[https://www.youtube.com/watch?v=xCu73WVg8Ps&t=2467s|(26) Avoiding Reactor Meltdown - YouTube]]
* [[https://github.com/nurkiewicz/reactor-workshop|nurkiewicz/reactor-workshop: Spring Reactor hands-on training (3 days)]]
* [[https://www.logicbig.com/tutorials/misc/reactive-programming/reactor.html|Reactive Programming with Reactor]]
* [[https://dlsrb6342.github.io/2019/11/23/Reactor-Tools-%EC%82%AC%EC%9A%A9%ED%95%B4%EB%B3%B4%EA%B8%B0/|Reactor-Tools 사용해보기]]