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.