Spring Boot @Async annotation w/ CompletableFuture on service or WebAsyncTask for async REST API to call another API

141 views Asked by At

I'm unsure which approach I should take for an async REST API which will call another API and wait for results and respond to the original requester:

a) annotate service with @Async and use with CompletableFuture?

or

b) use WebAsyncTaks with async executor?

For now, I have a "dirty" way which simply implements Runnable on a service and then run the service in a separate thread as

MyService service = new MyService(someObject, url);

Thread t = new Thread(service);
t.start();
0

There are 0 answers