Amar
Amar

Reputation: 971

Spring Async with 2 calls

I am using the annotation @Async in my methods.For code which makes a isolated calls to the third party the behavior of Async is perfect.But in one of the case when my program runs i make two calls to the 3rd party both in async mode.The problem now is that I want the calls to async made to third party in order.Need suggestion if that is possible.I want the async to remain as is(as performance is in question making the call to be invoked in sequence)Let me know if additional information is required.

Upvotes: 0

Views: 1557

Answers (1)

ColoWayno
ColoWayno

Reputation: 21

I believe if your first method returns a Future<> you can create a new @Async method that calls the first method then waits for the Future to complete. Then call the second method and wait or don't wait for it to complete.

Upvotes: 2

Related Questions