I have seen no magic in the parallelExecutor. It just passes a runnable /
Callable / Invokable to the worker queue and the worker simply calls its
run method. So there is nothing like dependency injection going on here.

I might use parallelExecutor to execute my processor, I am not sure. I can
create a service / object using the registery and get constructor and
private field injection working. But that is not enough unless I make my
inner worker job a PerThread service and use the registery to optain it
inside the parallel task. I will check this out.

But if you know a  way I can specify a method to invoke and the
dependencies are injected automatically (and I dont have to write it myself
using the registery to look up for services that apply to the parameters).
- Well I can do this but hey this is a IOC. It should be capable of doing
so.


2013/9/23 Lance Java <lance.j...@googlemail.com>

> Is there any reason why you can't just @Inject Session and start using it
> like a normal tapestry page or service?
>
> The only difference being that you need to @Inject PerThreadManager and
> call cleanup() in the rare case that you are NOT inside a tapestry request
> / response AND NOT using ParallelExecutor / PeriodicExecutor.
> On 22 Sep 2013 22:38, "Martin Kersten" <martin.kersten...@gmail.com>
> wrote:
>
> > @Lance
> > Using Hibernate SessionSource will just create a new session with no
> thread
> > local awareness. Is there another service that gives me a per thread
> > session? Would be nice to have a service that automatically gives the
> > session of the current thread? Especially if the thread local thingy is
> > working outside of the page processing?
> >
> > @Barry
> > I just managed to find out that my other service is also PerThread Scope
> so
> > I need support for this. I will check out if I can get the IOC to work
> > outside the page processing and have support for perThread scope.
> >
> > I will also try out a resteasy tapestry page to inject the service and
> > compose it as PerThread scope.
> > But I will use a simple worker thread to trigger the page call. Cron jobs
> > are good but I need the possibility to end the waiting phase and issue
> the
> > processing of tasks instantly.
> >
> >
> > 2013/9/22 Barry Books <trs...@gmail.com>
> >
> > > 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