0

Using Spring MVC I have a webservice that receives several parameters and inserts them to the Database returning to the client the id of inserted row. How can I execute other function after the id has been sent to the client? How can I schedule a method to run after the webservice return?

Rocky2014
  • 21
  • 2

1 Answers1

0

Spring supports @Async annotation.

Which means any call to the annotated method returns immediately. Hence you could call the method right before you return the response from your controller.

Check here for more details.

Another way is to use AOP and create a thread that handles the after response possessing!

Amanuel Nega
  • 1,899
  • 1
  • 24
  • 42
  • Hi Amanuel, thank you for your answer. I've done it with a TaskScheduler. It seems to be working. I've set it for a few moments later. Just for the other part to have time to receive the id that I sent on the response so that I can work with it from then on. I'll see how the Async works and if it's a better approach for this case. – Rocky2014 Dec 26 '16 at 21:14