spring boot2에서부터는  controller에서 @Async에서도

completableFuture를 리턴할 수 있다..

( 그 전에도 Async와 EnableAsync는 있었는데 completableFuture를 리턴하지는 못한것 같은데, 확인 중)

 

<사전지식>

1. Future(Java5 에 등장) 와 Observable간에 전환.  (마찬가지로 CompleatbleFuture와  Single간에 전환도 유사)

Observable<String> source = Observable.fromFuture(future);

source.subscribe(System.out::println);

 

2. Future vs CompletableFuture (Java8에 등장)  : ref
    CompletableFuture.complete() 함수를 호출해  Future를 수동으로 종료할 수 있음. 

    그 외 runAysnc, supplyAsync, thenApply, thenAccept, thenRun 등 함수들이 제공됨.

  

 


출처: https://12bme.tistory.com/570 [길은 가면, 뒤에 있다.]

 

[RxJava] RxJava 프로그래밍(1) - 리액티브 프로그래밍

서버 다수와 통신하게 되면 API 호출 각각에 콜백을 추가하게 된다. 콜백이 늘어나면 애플리케이션의 복잡성도 증가(callback hell)하게 된다. RxJava는 자바로 리액티브 프로그래밍을 할 수 있는 라이

12bme.tistory.com

https://12bme.tistory.com/570 

 

 

 

참고: https://howtodoinjava.com/spring-boot2/rest/enableasync-async-controller/#:~:text=1.-,Spring%20%40Async%20rest%20controller,application%20classes%20for%20asynchronous%20behavior.&text=The%20%40Async%20annotated%20methods%20can,result%20of%20an%20asynchronous%20computation.

 

Spring @Async rest controller example - Spring @EnableAsync

Spring @Async non blocking rest controller example. Learn to use spring async behavior with @EnableAsync annotation. Spring async completablefuture example.

howtodoinjava.com

 

Posted by yongary
,