spring-boot-completable-future icon indicating copy to clipboard operation
spring-boot-completable-future copied to clipboard

I just wanted to check whether is tested or not

Open mabujaber opened this issue 5 years ago • 3 comments
trafficstars

Hi!

I just wanted to make sure whether you tested if there is really a difference between two endpoints which one is made with ResponseEntity and the other CompletableFuture?

as per my experiments I found no difference! both makes the client blocked!

I add one more end point along with yours and make it non-competableFuture and I did ab testing

the result almost identical

mabujaber avatar Mar 08 '20 12:03 mabujaber

@mabujaber, CompletableFuture is used if we want to work with multi-threading. Please check my blog for more information. https://techshard.com/2019/09/15/multi-threading-in-spring-boot-using-completablefuture/

swathisprasad avatar Mar 10 '20 19:03 swathisprasad

I totally understand but in case of returning the CompletableFuture with values will really makes any difference?

mabujaber avatar Mar 11 '20 07:03 mabujaber

I totally understand but in case of returning the CompletableFuture with values will really makes any difference?

@mabujaber Basically when you use CompletableFuture, the task will be handled by non-main thread and that is why it is called Async Call. within this code, If you call uploadFile endpoint with multiple CSV files, you would notice that the return value is immediately passed to the caller(Client), thus it is behaving non-blocking. hope it helps

MortezaNaeimabadi avatar Nov 06 '20 12:11 MortezaNaeimabadi