Threads?

1 view
Skip to first unread message

Robert Fischer

unread,
May 12, 2008, 6:10:18 PM5/12/08
to groo...@googlegroups.com
Has anyone had Grails throw off a non-daemon thread to do some background processing? Does it cause
any problems?

~~ Robert.

Mike Hugo

unread,
May 12, 2008, 8:39:09 PM5/12/08
to groo...@googlegroups.com
I have used the Quartz plugin (http://grails.codehaus.org/Quartz+plugin) to do background processing and it works fine - might that do the trick for you?
Mike

Robert Fischer

unread,
May 12, 2008, 9:01:18 PM5/12/08
to groo...@googlegroups.com
What I'm thinking of is throwing off a thread when a particular GORM entity is created. The Quartz
plug-in would be the equivalent of the solution I had to do in Rails (cron and ./script/runner) -- I
was wondering if I could be a bit more direct in Groovy/Grails.

(Of course, I know I can parse XML in groovy/grails, so at least I'm up by one.)

~~ Robert.

Ted Naleid

unread,
May 12, 2008, 9:22:41 PM5/12/08
to groo...@googlegroups.com
I haven't done this (quartz has satisfied the threading/scheduling
needs for what we've done), but there shouldn't be any reason that you
couldn't have a before/after interceptor that spins off a thread and
does some processing. The only caveat would be that you'd need to
size things appropriately depending on how many objects you're
creating, how "bursty" the creation of that domain item is, and how
expensive the thread that gets spun off is.

Robert Fischer

unread,
May 12, 2008, 9:31:43 PM5/12/08
to groo...@googlegroups.com
Yeah, there's a whole scalability problem which I'm aware of.

I just wanted to be sure that there wasn't something weird with threads preventing requests from
flushing or something.

~~ Robert.

podollb

unread,
May 14, 2008, 9:00:31 AM5/14/08
to Groovy Users of Minnesota
In the past I've used code like this, which seems to work fine...

class SomeController {
...
def somerequest = {
render "Your request has been submitted!"
def whoWantsToKnow = params.email
def mythread = new Thread({
String results = processSomethingFor(whoWantsToKnow)
emailerService.sendEmail(whoWantsToKnow, "requested
information", results)
});
mythread.start()
}
}

On May 12, 8:31 pm, Robert Fischer <robert.fisc...@smokejumperit.com>
wrote:
Reply all
Reply to author
Forward
0 new messages