You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Leonardo K. Shikida" <sh...@gmail.com> on 2015/09/16 16:09:29 UTC

Are custom quartz schedulers persisted somewhere?

Hi

I am using a custom quartz scheduler in tomee 1.6.0 like this

@Startup
@Singleton
@DependsOn("SystemInitializerEJB")
public class TimerEJB{

    private Scheduler scheduler;

    @PostConstruct
    public void initialize() throws SchedulerException{
        log.info("Initialize "+this);
        StdSchedulerFactory factory = new StdSchedulerFactory();

factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
        scheduler = factory.getScheduler();
        scheduler.start();
        log.info("scheduler "+scheduler.getMetaData().getSchedulerName());
    }

(...)

Because I need to have full control over it and I don't want to mix it with
the default TomEE quartz scheduler.

I've noticed that sometimes, on server start, I get a message warning that
the scheduler already exists. But since it's a singleton, I am assuming it
will be created only once.

my.quartz.properties does not look special

#============================================================================
# Configure Main Scheduler Properties
#============================================================================

org.quartz.scheduler.instanceName = MyScheduler2
org.quartz.scheduler.instanceId = AUTO

#============================================================================
# Configure ThreadPool
#============================================================================

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5

it does not define a jobStore or a data source

Does TomEE/Quartz serializes the scheduler or stores it somewhere?

[]

Leo

Re: Are custom quartz schedulers persisted somewhere?

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
actually there's a preDestroy

    @PreDestroy
    public void stop() {
        try {
            System.out.println("scheduler stopping");
            scheduler.shutdown();
            System.out.println("scheduler stopped");
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }


I'm going to try quartz list then

thx

[]

Leo

On Wed, Sep 16, 2015 at 12:10 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Wait a sec, you dont rely on tomee scheduling so maybe you should ask
> quartz list there.
>
> Singleton is created once per app deployment so likely a missing preDestroy
> or so to cleanup your quartz.
> Le 16 sept. 2015 07:39, "Leonardo K. Shikida" <sh...@gmail.com> a écrit
> :
>
> > On server restart, may this singleton be deserialized and postConstruct
> be
> > called again, trying to recreate a scheduler that already exists?
> >
> > []
> >
> > Leo
> >
> > On Wed, Sep 16, 2015 at 11:13 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com>
> > wrote:
> >
> > > Hi
> > >
> > > By default we store it in memory but with the proper config it can be
> in
> > a
> > > database or anywhere
> > > Le 16 sept. 2015 07:10, "Leonardo K. Shikida" <sh...@gmail.com> a
> > écrit
> > > :
> > >
> > > > Hi
> > > >
> > > > I am using a custom quartz scheduler in tomee 1.6.0 like this
> > > >
> > > > @Startup
> > > > @Singleton
> > > > @DependsOn("SystemInitializerEJB")
> > > > public class TimerEJB{
> > > >
> > > >     private Scheduler scheduler;
> > > >
> > > >     @PostConstruct
> > > >     public void initialize() throws SchedulerException{
> > > >         log.info("Initialize "+this);
> > > >         StdSchedulerFactory factory = new StdSchedulerFactory();
> > > >
> > > >
> > > >
> > >
> >
> factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
> > > >         scheduler = factory.getScheduler();
> > > >         scheduler.start();
> > > >         log.info("scheduler
> > > "+scheduler.getMetaData().getSchedulerName());
> > > >     }
> > > >
> > > > (...)
> > > >
> > > > Because I need to have full control over it and I don't want to mix
> it
> > > with
> > > > the default TomEE quartz scheduler.
> > > >
> > > > I've noticed that sometimes, on server start, I get a message warning
> > > that
> > > > the scheduler already exists. But since it's a singleton, I am
> assuming
> > > it
> > > > will be created only once.
> > > >
> > > > my.quartz.properties does not look special
> > > >
> > > >
> > > >
> > >
> >
> #============================================================================
> > > > # Configure Main Scheduler Properties
> > > >
> > > >
> > >
> >
> #============================================================================
> > > >
> > > > org.quartz.scheduler.instanceName = MyScheduler2
> > > > org.quartz.scheduler.instanceId = AUTO
> > > >
> > > >
> > > >
> > >
> >
> #============================================================================
> > > > # Configure ThreadPool
> > > >
> > > >
> > >
> >
> #============================================================================
> > > >
> > > > org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
> > > > org.quartz.threadPool.threadCount = 10
> > > > org.quartz.threadPool.threadPriority = 5
> > > >
> > > > it does not define a jobStore or a data source
> > > >
> > > > Does TomEE/Quartz serializes the scheduler or stores it somewhere?
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > >
> >
>

Re: Are custom quartz schedulers persisted somewhere?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Wait a sec, you dont rely on tomee scheduling so maybe you should ask
quartz list there.

Singleton is created once per app deployment so likely a missing preDestroy
or so to cleanup your quartz.
Le 16 sept. 2015 07:39, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> On server restart, may this singleton be deserialized and postConstruct be
> called again, trying to recreate a scheduler that already exists?
>
> []
>
> Leo
>
> On Wed, Sep 16, 2015 at 11:13 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> wrote:
>
> > Hi
> >
> > By default we store it in memory but with the proper config it can be in
> a
> > database or anywhere
> > Le 16 sept. 2015 07:10, "Leonardo K. Shikida" <sh...@gmail.com> a
> écrit
> > :
> >
> > > Hi
> > >
> > > I am using a custom quartz scheduler in tomee 1.6.0 like this
> > >
> > > @Startup
> > > @Singleton
> > > @DependsOn("SystemInitializerEJB")
> > > public class TimerEJB{
> > >
> > >     private Scheduler scheduler;
> > >
> > >     @PostConstruct
> > >     public void initialize() throws SchedulerException{
> > >         log.info("Initialize "+this);
> > >         StdSchedulerFactory factory = new StdSchedulerFactory();
> > >
> > >
> > >
> >
> factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
> > >         scheduler = factory.getScheduler();
> > >         scheduler.start();
> > >         log.info("scheduler
> > "+scheduler.getMetaData().getSchedulerName());
> > >     }
> > >
> > > (...)
> > >
> > > Because I need to have full control over it and I don't want to mix it
> > with
> > > the default TomEE quartz scheduler.
> > >
> > > I've noticed that sometimes, on server start, I get a message warning
> > that
> > > the scheduler already exists. But since it's a singleton, I am assuming
> > it
> > > will be created only once.
> > >
> > > my.quartz.properties does not look special
> > >
> > >
> > >
> >
> #============================================================================
> > > # Configure Main Scheduler Properties
> > >
> > >
> >
> #============================================================================
> > >
> > > org.quartz.scheduler.instanceName = MyScheduler2
> > > org.quartz.scheduler.instanceId = AUTO
> > >
> > >
> > >
> >
> #============================================================================
> > > # Configure ThreadPool
> > >
> > >
> >
> #============================================================================
> > >
> > > org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
> > > org.quartz.threadPool.threadCount = 10
> > > org.quartz.threadPool.threadPriority = 5
> > >
> > > it does not define a jobStore or a data source
> > >
> > > Does TomEE/Quartz serializes the scheduler or stores it somewhere?
> > >
> > > []
> > >
> > > Leo
> > >
> >
>

Re: Are custom quartz schedulers persisted somewhere?

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
On server restart, may this singleton be deserialized and postConstruct be
called again, trying to recreate a scheduler that already exists?

[]

Leo

On Wed, Sep 16, 2015 at 11:13 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hi
>
> By default we store it in memory but with the proper config it can be in a
> database or anywhere
> Le 16 sept. 2015 07:10, "Leonardo K. Shikida" <sh...@gmail.com> a écrit
> :
>
> > Hi
> >
> > I am using a custom quartz scheduler in tomee 1.6.0 like this
> >
> > @Startup
> > @Singleton
> > @DependsOn("SystemInitializerEJB")
> > public class TimerEJB{
> >
> >     private Scheduler scheduler;
> >
> >     @PostConstruct
> >     public void initialize() throws SchedulerException{
> >         log.info("Initialize "+this);
> >         StdSchedulerFactory factory = new StdSchedulerFactory();
> >
> >
> >
> factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
> >         scheduler = factory.getScheduler();
> >         scheduler.start();
> >         log.info("scheduler
> "+scheduler.getMetaData().getSchedulerName());
> >     }
> >
> > (...)
> >
> > Because I need to have full control over it and I don't want to mix it
> with
> > the default TomEE quartz scheduler.
> >
> > I've noticed that sometimes, on server start, I get a message warning
> that
> > the scheduler already exists. But since it's a singleton, I am assuming
> it
> > will be created only once.
> >
> > my.quartz.properties does not look special
> >
> >
> >
> #============================================================================
> > # Configure Main Scheduler Properties
> >
> >
> #============================================================================
> >
> > org.quartz.scheduler.instanceName = MyScheduler2
> > org.quartz.scheduler.instanceId = AUTO
> >
> >
> >
> #============================================================================
> > # Configure ThreadPool
> >
> >
> #============================================================================
> >
> > org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
> > org.quartz.threadPool.threadCount = 10
> > org.quartz.threadPool.threadPriority = 5
> >
> > it does not define a jobStore or a data source
> >
> > Does TomEE/Quartz serializes the scheduler or stores it somewhere?
> >
> > []
> >
> > Leo
> >
>

Re: Are custom quartz schedulers persisted somewhere?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

By default we store it in memory but with the proper config it can be in a
database or anywhere
Le 16 sept. 2015 07:10, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :

> Hi
>
> I am using a custom quartz scheduler in tomee 1.6.0 like this
>
> @Startup
> @Singleton
> @DependsOn("SystemInitializerEJB")
> public class TimerEJB{
>
>     private Scheduler scheduler;
>
>     @PostConstruct
>     public void initialize() throws SchedulerException{
>         log.info("Initialize "+this);
>         StdSchedulerFactory factory = new StdSchedulerFactory();
>
>
> factory.initialize(this.getClass().getResourceAsStream("my.quartz.properties"));
>         scheduler = factory.getScheduler();
>         scheduler.start();
>         log.info("scheduler "+scheduler.getMetaData().getSchedulerName());
>     }
>
> (...)
>
> Because I need to have full control over it and I don't want to mix it with
> the default TomEE quartz scheduler.
>
> I've noticed that sometimes, on server start, I get a message warning that
> the scheduler already exists. But since it's a singleton, I am assuming it
> will be created only once.
>
> my.quartz.properties does not look special
>
>
> #============================================================================
> # Configure Main Scheduler Properties
>
> #============================================================================
>
> org.quartz.scheduler.instanceName = MyScheduler2
> org.quartz.scheduler.instanceId = AUTO
>
>
> #============================================================================
> # Configure ThreadPool
>
> #============================================================================
>
> org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
> org.quartz.threadPool.threadCount = 10
> org.quartz.threadPool.threadPriority = 5
>
> it does not define a jobStore or a data source
>
> Does TomEE/Quartz serializes the scheduler or stores it somewhere?
>
> []
>
> Leo
>