Search code examples
javaspringspring-mvcjava.util.concurrent

How to cancel Async spring method using two different apis


I have got two APIs
/books/generatreport and /books/cancelreport
what I am doing is when the user hits the first rest API books/generatereport it starts an async spring method which returns AsyncResult.
I am looking for is when the user hits books/cancelreport then it should cancel the task which was started by generatereport API.
How can I share the AsyncResult between two rest APIs?


Solution

  • Using servlet context solves my problem, as adding thing to servlet context is application level so this can be used for sharing information between two restful services.