users@glassfish.java.net

Re: How do I run a process within a web service?

From: <glassfish_at_javadesktop.org>
Date: Thu, 10 Sep 2009 17:21:21 PDT

What NBW wrote is technically correct, but the reality is different. Most any container will let you create a thread if you want, regardless of the what the spec says. It's not "officially" portable to do that, but it's "practically" portable.

First, if you simply want to stick in the Web Tier, it's kind of hard to use EJB Timers without an EJB tier.

There is a project called Quartz which can do what you want to do, mange processes within the web tier. Very mature, really popular.

I do recommend you have a way to shut down your long running thread, and tie the lifecycle to a Context Listener (start the job when the context listener starts, shut it down when the context listener shuts it down).

Other than that nuance, it's pretty straightforward.
[Message sent by forum member 'whartung' (redrocks_at_sbcglobal.net)]

http://forums.java.net/jive/thread.jspa?messageID=363655