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 grails.org soon.

15 comments:

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

Metamorfosis said...

Pelatihan SDM is a network marketing and training information or training an employee who has worked with many consulting firms and training institutions.
pendidikan dan pelatihan sdm, pelatihan akuntansi, sales marketing, manajemen bisnis, administrasi kantor, lembaga training motivasi, pelatihan sumber daya manusia, training manajemen, training sdm, informasi training, pusat pelatihan, pelatihan rumah sakit, training provider jakarta, training jakarta, training consultant jakarta, training center,

Shanthi Cabs said...

Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels

meldaresearchusa said...

It has become vital that students seek assistance from genuine and experienced custom Custom Written College Papers service providers if they intend to get the best pay for Custom Writing Assignment service in the market.

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

tipsontechnology

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]

CentORG said...

IIT JEE Coaching in Patna | IIT JEE Institute in Patna | NEET Coaching in Patna | Medical Coaching in Patna | JEE Mains, JEE Advance Coaching in Patna | Europa Classes

JEE Mains, JEE Advance Coaching in Patna
Hot offers on Amazon]
Tips on technology

Anushka Sen

meldaresearch said...

The quality of our Write My Essay Services are always high as we work hard to ensure that we uphold our good reputations at all time. We make sure that Write My Research Paper ordered are delivered on time and our prices are affordable to every student.

steve said...



شركة تنظيف منازل بجدة بالبخار ارخص شركة تنظيف منازل بجدة


شركة غسيل خزانات بالمدينة المنورة شركة تنظيف خزانات بالمدينة المنورة
افضل شركة تنظيف منازل بالمدينة المنورة افضل شركة تنظيف منازل بالمدينة المنورة

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

Florahmelda said...

Business Management coursework writing service learners have an advantage of hiring the best business research writing service that is familiar with business term paper writing services for their Business Essay Writing Services.