Just a note

Romain had it in a blog already since 2012... next time I'll do some
research first

http://rmannibucau.wordpress.com/2012/08/22/tomee-quartz-configuration-for-scheduled-methods/

Tested here using 1.6.0.2 and it works like a charm, for both ways (static
and dynamic timers)

Curiously, Quartz works as a cluster even if tomee is not clustered (very
smart).

Also noticed that this configuration needs some extra jars (probably
indicated somewhere in the quartz documentation, I guess, such as c3p0) and
my quartz DB script had a little bug (probably outdated -
https://code.google.com/p/myschedule/issues/detail?id=131)

Other than that, it just seems to work very well.

Thanks again, pals.

Leo




[]

Leo

On Fri, Oct 17, 2014 at 10:41 AM, Leonardo K. Shikida <shik...@gmail.com>
wrote:

> Thanks Andy and Romain. That's exactly what I was looking for.
>
> []
>
> Leo
>
> On Thu, Oct 16, 2014 at 11:37 AM, Andy Gumbrecht <agumbre...@tomitribe.com
> > wrote:
>
>> Hi Leonardo,
>>
>> Never feel like a question is dumb if you're searching for an answer.
>> That's why we are here.
>>
>> You will find information on clustering Quartz using a JDBC JobStore
>> here: http://quartz-scheduler.org/generated/2.2.1/html/qs-all/#
>> page/Quartz_Scheduler_Documentation_Set/re-cls_
>> cluster_configuration.html#
>>
>> Just make sure those properties are consistent across your TomEE cluster
>> and you'll be fine.
>>
>> The @Schedule is more tricky as you will be responsible for obtaining a
>> cluster wide lock from that method.
>> The easiest way would be to configure a DataSource to a central database
>> that is accessible by all the TomEE instances in the cluster - Use a simple
>> table with a BIT type and a DATETIME
>> Whichever '@Schedule' method gets the lock can then run the operation
>> (and unlock afterwards, so use a try/finally block) - The date can be used
>> to check for a lock timeout if a method fails to unlock for whatever reason
>> (a crash for example).
>>
>> Andy.
>>
>>
>> On 16/10/2014 12:27, Leonardo K. Shikida wrote:
>>
>>> Hi
>>>
>>> this doubt may sound dumb, but if I have an EJB with a scheduled task
>>> like
>>>
>>>      @Schedule(dayOfWeek = "*")
>>>      public void runMeDaily() {...}
>>>
>>> and if I am in a clustered environment, is there any way to make this job
>>> run in only one of the instances? (only once)
>>>
>>> of course, I can set a flag somewhere and check it before the execution
>>> of
>>> such task, so only the first cluster instance would run it, but I am
>>> curious if it's possible using some configuration magic.
>>>
>>> another doubt is: if I have 2 clustered tomee instances, how do I make
>>> both
>>> point to the same scheduler? By scheduler I mean something like
>>>
>>> Scheduler scheduler = new StdSchedulerFactory().
>>> getScheduler("myScheduler");
>>>
>>> My feeling is that my cluster will need a centralized quartz scheduler
>>> service somehow, so if there's some way to do that using tomee, it would
>>> be
>>> useful for me.
>>>
>>> TIA
>>>
>>> Leo
>>>
>>>
>>
>> --
>>   Andy Gumbrecht
>>   https://twitter.com/AndyGeeDe
>>   http://www.tomitribe.com
>>
>>
>

Reply via email to