I have a spring boot microservice where we call multiple services(Lets say Service A and Service B). I am trying to call these two services Asynchronously on multiple threads based on some conditions and once processing is completed I would like to merge the response from Service A and ServiceB.
I know we can use @Async to run a process asynchronously and use ExecutorService to start multiple threads for a service.
But i am not Sure How to keep all things together. So looking for any suggestions here?
@Async
Service A(thread1,thread2) \
MicroService / (Merge from Response of ServiceA and ServiceB)
\ @Async
Service B(thread1,thread2) /
I know this is mostly theoretically explained above, but i tried following / going through multiple websites but Most of the articles either explains about Aync or Multithreading but not sure how to wait and run two process in Async in multiple threads and continue execution after these two service calls are completed!
Any Suggestions or leads are appreciated! TIA :)