Fork me on GitHub

28 May 2010

Grails Spring Events Plugin

Following on from my last post I've developed a Grails plugin that packages the asynchronous events behaviour up and adds some extra useful functionality.

In addition to the asynchronous event processing the plugin gives you:
  • A publishEvent method attached to all domain classes, controllers and services.
  • A Hibernate session bound to the listener thread for the duration of the notification so that listeners can access lazy-loaded properties, etc.
  • The ability to have a "retry policy" for certain types of failed notifications on individual listeners. This is particularly useful for listeners that do things like invoking external web-services that may be periodically unavailable.

To install the plugin just use:
grails install-plugin spring-events

The code and some more detailed documentation is on GitHub. I'll be migrating the docs to the plugin's page on soon.


Fung said...

Thanks for this. I've been struggling with how to resolve the LazyInitializationException errors I get with Hibernate when my ApplicationEvent listener tries to use lazily loaded objects. I adapted your Grails code for use with regular Spring and it's working great!

Altair said...

Is there a way to make a particular event synchronous?

For most of my events, having them asynchronous is desirable, however for a select few synchronous execution is required.

I suspect that this would require me to create my own publishing service, as well as changes to the plugin itself (so that it did not use the taskExecutor when notifying listeners).

CentORG said...

Anushka Sen:- She is an actress from India. she works on many roles in his tiny age. The main role of his carrier was Balveer as Mehar. Peoples calls him The purple star of India. His age in this time for about 17 years and she gets about three big roles in his acting carrier. And now she is working on Manikarnika(Jhansi ki Rani).

Anushka Sen

CentORG said...


learn every time new tips on technology

Hey my audience, in this website we’ll post about many tips on technology. many tips on hacking, education and many entertainment niche. i’ll post somethin Tips on technology
g special for you, Everyday
So check out it from here

CentORG said...

sale all product in hindi

Hindisales provide you most productive Offers notification for you. If you Want to buy any products for you. Just check offers on that products in hindisales and check it out from here
Hot offers on Amazon]

Repairtech Solutions said...

I really love your site.. Pleasant colors & theme. Did you create this website yourself? Please reply back as I’m attempting to create my very own site and want to find out where you got this from or exactly what the theme is called. Cheers! onsite mobile repair bangalore I love it when folks come together and share views. Great website, keep it up! asus display repair bangalore Great information. Lucky me I discovered your website by accident (stumbleupon). I've book-marked it for later! huawei display repair bangalore

Repairtech Solutions said...

It’s hard to find well-informed people about this topic, but you seem like you know what you’re talking about! Thanks online laptop repair center bangalore You should take part in a contest for one of the most useful websites online. I am going to highly recommend this web site! dell repair center bangalore

Repairtech Solutions said...

Aw, this was an incredibly good post. Taking a few minutes and actual effort to create a superb article… but what can I say… I procrastinate a lot and don't seem to get anything done. macbook repair center bangalore I’m impressed, I have to admit. Rarely do I encounter a blog that’s equally educative and engaging, and without a doubt, you've hit the nail on the head. The problem is something that too few folks are speaking intelligently about. Now i'm very happy that I found this in my hunt for something regarding this. acer repair center bangalore

hameedudhaaam said...

Thanks for sharing this best stuff with us! Keep sharing! I am new in the blog writing. All types blogs and posts are not helpful for the readers. Here the author is giving good thoughts and suggestions to each and every reader through this article. literature-essay Quality pay to write my assignment of the content is the main element of the blog and this is the way of writing and presenting.