spring-boot-completable-future
spring-boot-completable-future copied to clipboard
I just wanted to check whether is tested or not
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, 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/
I totally understand but in case of returning the CompletableFuture with values will really makes any difference?
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