It's much easier to just create a page at let Tapestry handle the
threading. That's what it's built to do.

You can just add synchronized to method if you only want one invocation at
a time.

If you don't want Hudson. Then I'd create a cron service that takes a
configuration of times/urls and calls the pages. That would make it easy to
work either way. I have used Tapestry scheduling but found it's much better
to to have external control over running tasks. I think someone said

Any sufficiently complicated application contains an ad hoc,
informally-specified, bug-ridden <http://en.wikipedia.org/wiki/Computer_bug>,
slow implementation of half of Hudson.


On Sun, Sep 22, 2013 at 4:53 AM, Martin Kersten <martin.kersten...@gmail.com
> wrote:

> Thanks Lance. This cleanup advise was what i was looking for. Cheers.
>
>
> 2013/9/22 Lance Java <lance.j...@googlemail.com>
>
> > Igor has written a blog about scheduling jobs with tapestry here
> >
> >
> http://blog.tapestry5.de/index.php/2011/09/18/scheduling-jobs-with-tapestry/
> >
> > The hibernate session provided by tapestry is a singleton and can be
> > injected as any other service. The singleton is a proxy to a per-thread
> > instance which is created on demand and cleaned up by
> > PerThreadManager.cleanup().
> > If you use the PeriodicExecutor or the ParallelExecutor then the (per
> > thread) hibernate session will be cleaned up after your job runs. If you
> > are not using these services (ie you are using java.util.concurrent.*
> > directly) then you will need to call either PerThreadManager.cleanup() or
> > Registry.cleanupThread() explicitly to close the hibernate session.
> >
> >
> >
> > On 22 September 2013 08:12, Martin Kersten <martin.kersten...@gmail.com
> > >wrote:
> >
> > > :) I know Barry. I marked your former post about this. But I dont want
> a
> > > page right now.
> > >
> > > But this calling it directly ... well that is a good one. But
> > object.notify
> > > is also easy and makes it possible to assume only one invocation of the
> > > processor is running once at a time per JVM.
> > >
> > > But sadly making the process a singleton I have again the Hibernate
> > Session
> > > stuff.
> > >
> > >
> > > 2013/9/21 Barry Books <trs...@gmail.com>
> > >
> > > > Here is what I do:
> > > >
> > > > 1. Write a simple service that just performs the action you want
> > > > 2. If you need real time processing just call it.
> > > > 3. Create a page that just calls the service and schedule accessing
> > that
> > > > page with Hudson/curl
> > > >
> > > >
> > > > On Sat, Sep 21, 2013 at 2:41 PM, Martin Kersten <
> > > > martin.kersten...@gmail.com
> > > > > wrote:
> > > >
> > > > > Hi there,
> > > > >
> > > > >
> > > > >    I need to implement a service that reads tasks (descriptions)
> from
> > > the
> > > > > database, does some tasks and sleeps again. The thread must be able
> > to
> > > > woke
> > > > > up if an other service demands just in time processing.
> > > > >
> > > > > Requirements:
> > > > > 1. Need a Hibernate Session inside the main loop.
> > > > > 2. Needs to be able to woke up (just use Object.notify and
> > > Object.wait).
> > > > > 3. Needs to sleep for a couple of minutes, check db for work and
> > sleep
> > > > > again.
> > > > > 4. On shut down it needs to suspend and decompose gracefully.
> > > > >     What is the best way to do so?
> > > > >
> > > > > So first I looked at periodic job etc. Nothing to use. So it ends
> up
> > > > doing
> > > > > some kind of a
> > > > > service that spawns a thread and the thread does all the
> progressing.
> > > > >
> > > > > The thread itself uses a runnable to guard against failures and
> those
> > > > > failures are logged
> > > > > within each task during which the failure occures.
> > > > >
> > > > > So here comes the big question:
> > > > >
> > > > > What should I do.
> > > > >
> > > > > The naive answer is using a SessionSource and create a session each
> > > time
> > > > > the thread's
> > > > > runnable starts the processing.
> > > > >
> > > > > Another idea would be set up the worker part as a service that is
> > > created
> > > > > every time and
> > > > > let the IOC do all the session creation and handling. But I fear
> that
> > > > this
> > > > > is way more
> > > > > complicated then the SessionSource idea.
> > > > >
> > > > > The decomposition on the teardown of the tapestry application
> > requires
> > > to
> > > > > deal with
> > > > > certain kind of listeners. What is the best service to add the
> > listener
> > > > > too?
> > > > >
> > > > >
> > > > > Thanks in advance,
> > > > >
> > > > > Martin (Kersten)
> > > > >
> > > >
> > >
> >
>

Reply via email to