Results 1 to 10 of 10

Thread: Dynamic Job Scheduling using Spring

  1. #1

    Default Dynamic Job Scheduling using Spring

    Hi,

    In my application some jobs are scheduled using spring on top of Quartz. So, we are giving the scheduled time in the configuration file itself. So, whenever there is a need to change the schedule time, we are manually changing that xml file and redeploying the application once again and restarting the server. FYI, the application is running on tomcat web server.

    But now we want to make it dynamically where we can cange the schedule timings.

    ========================
    <bean id="readIVAVfromCLSJobInvokerCronTrigger" class="org.springframework.scheduling.quartz.CronT riggerBean">
    <property name="jobDetail" ref="readIVAVfromCLSJobInvoker" />
    <!-- run every month, any day of the month, from monday till saturday, 17:15 -->
    <property name="cronExpression" value="0 30 12-18 ? * MON-SAT" />
    </bean>
    ==========================

    Can anyone suggest me the possible solutions for this.

  2. #2
    Join Date
    May 2007
    Posts
    24

    Default

    Did you ever get this figured out? If so, please post your solution.

  3. #3
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    4

    Default

    Please post your solution, if this was resolved.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Can you not use a propertyPlaceHolder to externalise the timings and then use JMX to refresh the application context?
    Colin Yates
    SpringSource - http://www.springsource.com - Spring Training, Consulting, and Support - "From the Source"
    Please read http://www.springframework.org/documentation
    Co-Author of Expert Spring MVC + Web Flow.

  5. #5
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    4

    Default

    I am not sure how i do it.

    Actually my requirement is like this:

    In a DB Table i will have the name of the class and the method that need to be executed at regular intervals. Any needed params will be stored in an XML or DB.

    Now i have a Scheduler that is triggered every 15 minutes.
    This scheduler should have the ability to schedule the events that are in the DB as quartz cron jobs.

    I have done this but through a different approach. Now all my classes extend Spring's JobDetailBean.

    But what i want to do is eliminate this extends, and then have the ability to execute any method inside the class instead of executeInternal or execute?

    Could you please suggest a way to do this?
    Thanks in Advance

  6. #6
    Join Date
    Nov 2007
    Posts
    122

    Question

    Did you figured it out? I am looking for exactly same thing. Please suggest me your solution to this?

    Regards
    Harshi

  7. #7
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    4

    Default Dynamic Scheduling

    I found this solution in some other place, I dont exactly remember where.

    The idea here is simple.

    First create a Manager job that runs every 15 odd minutes (depending on how quick the turnaround is needed.) The job of this Manager is to look into any updates in the DB in the last 15 (or the given turn around time) minutes and enforce the changes.

    The Manager creates individual schedulers per entry in the table and tracks them.

    Then any updates to these schedulers are tracked and enforced by the Manager.

    Pradeep

  8. #8
    Join Date
    Nov 2007
    Posts
    122

    Default

    Thanks Pradeep.

    That means we end up running multiple schedulers ,one per Job Manager and each scheduler based on database settings?

    Basically one scheduler starts all other schedulers? Is it okay run multiple schedulers rather than multiple jobs with single scheduler?

    Would it be better to run one scheduler and add triggers and jobs at run time in the code rather than in spring configuration?

    Here is my requirement.

    In the database we store which class need to be executed at what time for each customer.

    I need to load all the configurations from the database and schedule based on it.

    After it stopped it needs to look in the database again to see any thing is changed and based on that new scheduling should happen?
    Last edited by harshi; Apr 13th, 2009 at 09:49 PM.

  9. #9
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    4

    Default Dynamic Scheduling

    Hi Harshi,

    Depending on the load on the server we can go for one or multiple schedulers. The quartz schedulers are light weight as such.

    For your requirement you can go for one manager scheduler and a executing scheduler with multiple triggers for each customer. The Manager Scheduler can then check the db for regular updates and propagate the same to the individual triggers.

    Pradeep

  10. #10
    Join Date
    Feb 2007
    Posts
    4

    Default I solved the same issue

    I had the same requirements: I needed to dynamically create/update the scheduling of quartz jobs within a spring web application, recovering the triggering/job options from a DB instead of a config file.

    I finally managed to make it work: I basically kept a reference to the Quartz Scheduler (by injection) and use it to access to the triggers/jobs when needed.

    Take a look at this post on another thread for details:
    http://forum.springsource.org/showth...ghlight=quartz

    It works great for me. Hope it helps.

    Geez.

Posting Permissions

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