caelum / vraptor-quartzjob

A simple quartz job
3 stars 11 forks source link

Statefuljob #13

Open MAAARKIN opened 9 years ago

MAAARKIN commented 9 years ago

We can create interface StatefulCronTask to create a statefuljob.

Would be nice if we can put implements StatefulCronTask and we use this to implement our job without concurrency.

csokol commented 9 years ago

@MAAARKIN, what happens if you add @ApplicationScoped to your job? I think it will keep its state between executions.

MAAARKIN commented 9 years ago

I have 2 jobs, FirstJob and SecondJob, i need that SecondJob just execute when the FirstJob finish, i think that @ApplicationScoped doesn't solve.

csokol commented 9 years ago

How would a stateful job support help you with that problem? What you mean exactly by stateful job?

On Mon, Aug 3, 2015 at 11:14 AM Marcos Antonio do Nascimento Filho < notifications@github.com> wrote:

I have 2 jobs, FirstJob and SecondJob, i need that SecondJob just execute when the FirstJob finish, i think that @ApplicationScoped doesn't solve.

— Reply to this email directly or view it on GitHub https://github.com/caelum/vraptor-quartzjob/issues/13#issuecomment-127257097 .

MAAARKIN commented 9 years ago

Well, i think that statefuljob solves the problem of execution concurrently. Will not?

garcia-jj commented 9 years ago

Stateful job won't resolve your case.

StatefulJob means you will have one instance only for the same job instance. Before trigger a job Foo, Quartz will check if there is another instance for Foo. If true, Quartz won't trigger another instance.

This is the same behavior of singleton EJB with @Lock(READ).

MAAARKIN commented 9 years ago

@garcia-jj omg, so sorry garcia. Probably I got it wrong, i will reformulate my question.

Is possible create a jobs with the same trigger/frequency respecting some ordination? something like what happens with @interceptors (before/after).

obs: sry about my english.

garcia-jj commented 9 years ago

You can use CDI events to solve your case. When job 1finish, trigger the event, and the second class will @Observes that event.