Continue Async Task after return statement too.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Continue Async Task after return statement too.

bimaltamang531
 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.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/1fa24363-a906-4d4f-bc56-6d69167940e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.