Continue Async Task after return statement too.

10 views
Skip to first unread message

bimalta...@gmail.com

unread,
May 9, 2018, 1:37:51 PM5/9/18
to Grails Dev Discuss
 I have a Rest API, where I have called an aws service and save the records on a single endpoint at the same time. In order to respond quickly, I want to run the aws service asynchronously, even after the API responds too in grails. Please suggest how could I achieve it?

I have included a prototype of the  async task implemented in a service  as :

def method1(){

        task {
       // time consuming service call.
        Thread.sleep(50000)
   }.onError{ Throwable error ->
         println ":::::: Error :::::"+error.getMessage()
  }
 saverecords();
return ["msg":"success"]
}

I want to return the success message on the complete execution of saverecords() function and continue the task (process) in the background. But i have got an error on the completion of task thread execution.

Reply all
Reply to author
Forward
0 new messages