• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Asynchronous method in groovy

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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 ?

Thanks,
+Ketan Parekh
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just because Grails uses spring under the hood doesn't really mean all of spring is supported, at least not without some more configuration. You would be better off using this plugin.
 
Ketan Parekh
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 unit test 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 ?

+Ketan B. Parekh
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic