Producer/consumer in Grails?
- by Mulone
Hi all,
I'm trying to implement a Consumer/Producer app in Grails, after several unsuccessful attempts at implementing concurrent threads.
Basically I want to store all the events coming from a clients (through separate AJAX calls) in a single queue and then process such a queue in a linear way as soon as new events are added.
This looks like a Producer/Consumer problem:
http://en.wikipedia.org/wiki/Producer-consumer_problem
How can I implement this in Grails (maybe with a timer or even better by generating an event 'process queue')?
Basically I'd like to a have a singleton service waiting for new events in the queue and processing them linearly (even if the queue is loaded by several concurrent processes).
Any hints?
Cheers!