[Yanel-dev] Running background jobs in the background using threads

Michael Wechner michael.wechner at wyona.com
Wed Nov 24 14:40:28 CET 2010


Hi Balz

On 11/23/10 7:48 AM, Balz Schreier wrote:
> Hi Michael,
> I have just quickly read your mail and I think it would be a great =

> idea to look into the Glassfish Application Server, as one framework =

> in there (called Grizzly) is solving this properly (uses NIO for the =

> threading part and leverages protocols like Comet / Bayeux Protocol =

> for the front end part, and)... and as far as I know, Grizzly is =

> reusable as a single component... sounds ideal to me for Yanel?
>
> http://grizzly.java.net/


Thanks very much for pointing this out. Will try to have a closer look =

at it shortly.
>
> The advantage of this would be that it is heavily tested and used =

> already in large productive applications... on top of that, I have the =

> greatest respect from "threading in java" :-) I know it got much more =

> convenient with the advent of java.util.concurrent by JDK 1.5, but =

> none the less: Brian G=F6tz still writes: "it does not matter how good =

> you are in programming, a threading application has always bugs":
>
> By the way: His book is great:
> http://www.briangoetz.com/pubs.html
>
> I can bring it to the office once, if you're interested.

please do :-)

Thanks

Michael
>
> Cheers
> Balz
>
> On Mon, Nov 22, 2010 at 10:16 PM, Michael Wechner =

> <michael.wechner at wyona.com <mailto:michael.wechner at wyona.com>> wrote:
>
>     Hi
>
>     Quite often one has to process something which can take more time
>     than which is expected from
>     a regular request. Hence it's nice if one can start threads
>     running in the background and Yanel
>     already sends a response with a note saying "hey, we are working
>     on it ... please stay tuned ...".
>
>     Yanel does offer such a component which simplifies such threads:
>
>     src/impl/java/org/wyona/yanel/impl/resources/usecase/thread/ThreadUse=
caseResource.java
>
>     and in order to stay tuned the thread ID is attached to the HTTP
>     session. But the problem with this
>     approach is that the session might expire before the job is
>     finished, hence I have added a note to
>
>     Index:
>     src/impl/java/org/wyona/yanel/impl/resources/usecase/thread/ThreadUse=
caseResource.java
>     =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>     ---
>     src/impl/java/org/wyona/yanel/impl/resources/usecase/thread/ThreadUse=
caseResource.java
>        (revision 54828)
>     +++
>     src/impl/java/org/wyona/yanel/impl/resources/usecase/thread/ThreadUse=
caseResource.java
>        (working copy)
>     @@ -123,6 +123,7 @@
>          * @return thread or null if the thread is not attached to the
>     session.
>          */
>         public UsecaseThread getThread() {
>     +        // TODO: Is it really a good idea to set/get the thread
>     ID within the session, because what if the session expires?!
>             HttpSession session =3D
>     getEnvironment().getRequest().getSession();
>             return UsecaseThread.getThreadFromSession(session,
>     getThreadID());
>         }
>
>     I think it probably would be safer to attach it to the user
>     profile which has started it (in case it has been started
>     by a user).
>
>     WDYT?
>
>     Cheers
>
>     Michael
>     -- =

>     Yanel-development mailing list Yanel-development at wyona.com
>     <mailto:Yanel-development at wyona.com>
>     http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wyona.org/pipermail/yanel-development/attachments/2010112=
4/7385e9a8/attachment.htm


More information about the Yanel-development mailing list