transactional message publishing from a grails service
Hi all,
My project is a groovy/grails project. In essence, some of my groovy transactional service instance-methods will be doing the message publishing, with fire-and-forget semantics.
For those unfamilliar with Grails, a Grail Service is pretty much like a java bean annotated with @Service stereotype and @Transactional (propagation:required). So I think that, provided that the grails framework is doing its transaction demarkation in a really weird way, a grails service method will behave just like an normal Java class method. Maybe I should have even left grails out of the picture here 
In those 'do-some-work and publish a message'-scenarios, I need to make sure that a message only gets published after a regular ORM transaction has been committed. The consumption of that message will be done asynchronously, and therefore in a different transaction which is fine. In time, I will probably add JMS or AMQP to do this properly and I know Spring Integration will help me out there too.
So before I dive in I would like to do some fact checking here...
-1. I assume that I can declare an interface in Java (maybe even in groovy but that's hardly important) that I configure to be a Spring Integration Gateway and inject that into my grails service. Nothing different from a standard java project here. Is this correct?
-2. Can I use spring integration to make sure that the message only gets published *after* the transaction on my service method has been committed? If I read the SI manual (chapter 27), it seems to me that my usecase falls in the 'User process' category. Further reading almost leads me to believe that what I want is what is provided by SI automagically
Is that correct? If not, what other solution pattern should I consider?
Hope somebody can help me out
Last edited by mirror303; Jan 28th, 2011 at 08:54 AM.
Reason: added some pointers for those unfamiliair with Grails
Hans Westerbeek
Software Engineer