Results 1 to 10 of 10

Thread: SchedulerFactoryBean autoStartup property not working

  1. #1
    Join Date
    Mar 2006
    Posts
    1

    Default SchedulerFactoryBean autoStartup property not working

    When I load up my application, I do not want my Quartz scheduling apps to start automatically. There seems to be a property in Spring to do such a thing.

    SchedulerFactoryBean
    setAutoStartup(boolean autoStartup)
    Set whether to automatically start the scheduler after initialization.

    However when I set this property to false, my scheduling app still runs automatically.

    Here is what is in my application context:
    <bean class="org.springframework.scheduling.quartz.Sched ulerFac toryBean">
    <property name="triggers">
    <ref bean="cronTrigger"/>
    </property>

    <property name="autoStartup">
    <value>false</value>
    </property>

    </bean>

    Any help on why this may be occurring would be appreciated.

    I am running Spring 1.2.6/ Quartz 1.5.2
    Thanks!
    Spirit.J

  2. #2
    Join Date
    Oct 2006
    Location
    USA
    Posts
    4

    Default

    When the SchedulerFactoryBean starts up, it retrieves a Schedule from the SchedulerFactory using the "scheduleName" attribute. If this is not set in the configuration, it will not get the correct scheduler.

    So, just add the "schedulerName" property ...


    <property name="schedulerName">
    <value>cronScheduler</value>
    </property>

  3. #3
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    15

    Default

    Can someone tell me whether this is good advice or not. I'm struggling with the same issue and I can't see how this advice helps.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Are you saying that autoStartup doesn't work? What actually happens?

  5. #5
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    15

    Default

    I'm actually in exactly the situation that the original poster was in. i.e. that I want to define a schedule but disable it until I programmatically tell it to start.

    spiritj said:
    When I load up my application, I do not want my Quartz scheduling apps to start automatically.
    The answer from jlong just didn't seem to answer the question.

    I've added the following to my configuration:

    Code:
    <property name="schedulerName">
    <value>cronScheduler</value>
    </property>
    But that doesn't stop my quartz jobs from firing.

    For the record here's what I need to do:

    I have an intra-day job which runs every 5 mins, this needs to be disabled at certain times when either the business don't want it to run, or when our end-of-day batch is running. It also should not start running when the application server comes up. It must wait until another process tells it to start doing it's thing. (This job is part of a huge suite of batches, all written in different languages on different machines, all coordinated using Autosys - which is like an enterprise wide distributed cron)

  6. #6
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    15

    Default

    I've set up my scheduler like this:

    Code:
        <bean id="schedulerFactoryBeanShouldRunOnStartup" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
                <list>
                    <ref bean="completedExceptionMonitorTrigger"/>
                    <ref bean="runningExceptionMonitorTrigger"/>
                    <ref bean="completedGarbagedMonitorTrigger"/>
                    <ref bean="eodCompletedMonitorTrigger"/>
                </list>
            </property>
        </bean>
        
        <bean id="schedulerFactoryBeanShouldNOTRunOnStartup" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="autoStartup" value="false"/>
            <property name="schedulerName" value="cronScheduler"/>
            <property name="triggers">
                <list>
                    <ref bean="eodRunningMonitorTrigger"/>
                    <ref bean="intradayInfoRunMonitorTrigger"/>
                    <ref bean="intradaySatWarningRunMonitorTrigger"/>
                    <ref bean="intradaySunWarningRunMonitorTrigger"/>
                </list>
            </property>
        </bean>
    But the second scheduler, schedulerFactoryBeanShouldNOTRunOnStartup, still starts when the application server is started.

  7. #7
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    15

    Default

    At some point after startup an external job calls an EJB and that will get a handle to schedulerFactoryBeanShouldNOTRunOnStartup from Spring and tell it to start using the SchedulerFactoryBean.start() method.

  8. #8
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    15

    Default

    Further testing appears to indicate that the autoStartup property is now working. I must have had it configured incorrectly in the first instance.

    Thanks for putting up with my lengthy posts.

  9. #9
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote Originally Posted by Flynn View Post
    Further testing appears to indicate that the autoStartup property is now working. I must have had it configured incorrectly in the first instance.
    I didn't even get chance to respond . I was kind of surprised in the first instance that this didn't work, glad to know it does.

    Quote Originally Posted by Flynn View Post
    Thanks for putting up with my lengthy posts.
    Not a problem .

  10. #10
    Join Date
    Oct 2007
    Posts
    5

    Default

    Quote Originally Posted by jlong View Post
    When the SchedulerFactoryBean starts up, it retrieves a Schedule from the SchedulerFactory using the "scheduleName" attribute. If this is not set in the configuration, it will not get the correct scheduler.

    So, just add the "schedulerName" property ...


    <property name="schedulerName">
    <value>cronScheduler</value>
    </property>
    For me it worked just fine. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •