문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
reactive_programming:reactor [2018/12/26 17:10] kwon37xi |
reactive_programming:reactor [2020/11/17 15:18] (현재) kwon37xi |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* http:// | * http:// | ||
* [[reactive_programming: | * [[reactive_programming: | ||
+ | * [[https:// | ||
+ | |||
+ | ===== 동기 호출을 비동기로 전환하기(JDBC 등) ===== | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[java: | ||
+ | |||
+ | <code java> | ||
+ | Mono blockingWrapper = Mono.fromCallable(() -> { | ||
+ | return /* make a remote synchronous call */ | ||
+ | }); | ||
+ | blockingWrapper = blockingWrapper.subscribeOn(Schedulers.elastic()); | ||
+ | </ | ||
+ | |||
+ | <code java> | ||
+ | @GetMapping(value = "/ | ||
+ | public Flux< | ||
+ | return Flux.defer(() -> Flux.fromIterable(repository.findByFromDateGreaterThanEqual(new Date(1486980000L)))) | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code java> | ||
+ | @Configuration | ||
+ | public class SchedulerConfiguration { | ||
+ | private final Integer connectionPoolSize; | ||
+ | public SchedulerConfiguration(@Value(" | ||
+ | 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(" | ||
+ | this.repository = repository; | ||
+ | this.scheduler = scheduler; | ||
+ | } | ||
+ | public Mono< | ||
+ | return async(() -> repository.findAll()); | ||
+ | } | ||
+ | private <T> Mono< | ||
+ | return Mono.fromCallable(callable).publishOn(scheduler); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Tuning ===== | ||
+ | * [[reactive_programming: | ||
===== 참조 ===== | ===== 참조 ===== | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
* [[http:// | * [[http:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// |