I am using grails 1.3.4. We have a scenario where a user uploads a file on the web page and hits the submit button. The controller calls the grails service class and calls a method xyz(). The xyz() method is required to be asynchronous. We want the control to return back and while the xyz() method does some processing. The service class method has been annotated with @Async but we see the flow synchronised.
It seems like the grails service class is not recognizing the spring annotation.
Am I missing something or anyone has other ideas on how to make the method perform async ?
Intially we were trying to use the spring @Async with grails but we were not successful it seemed like grails was not able recognise it. I looked at that plugin mentioned in the Grails Doc and were able to do it. Thanks Greg Appreciate for your help.
Now we are writing the unittest but some how the instance variable "def backgroundService" is not getting injected. Is there a way to mock it (since its plugin we were not able to mock it) or to inject it so I can unit test my method ?
In a unit test, you'd have to mock it. Unfortunately, I don't know how to tell you to do that. You might have better luck on the grails mailing list when it comes to plugin specific questions, as this seems to be. Most of the plugin authors monitor that list closely.