Results 1 to 9 of 9

Thread: Using Quartz inside SpringFramework

  1. #1
    Join Date
    Aug 2004
    Posts
    6

    Default Using Quartz inside SpringFramework

    Sorry if this is something I am just missing in the docs, but I have looked all over and see now examples of doinf this.

    I want to configure 100% of a Quartz Scheulder from my spring.xml. I assume I am to use SchedulerFactoryBean for this. I am looking for an example. I see many where JobDetailBeans are used and such, this is not want I am looking for.

    What I want/need:
    100% of Quartz Scheduler setup in spring.xml
    Using JDBC JobStore, not just datasource but the whole JobStore as jobStores control many VERY important settings like TablePrefix.
    Allow for start and stop of scheduler (no auto start or stop)

    Do I need to just wrap a Quartz Scheduler and all the config needs myself and use spring to call my wrapped version? Or am I missing something that will do this.

    Again any help or example would be a big help.

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    The org.springframework.scheduling.quartz.LocalDataSou rceJobStore extends the Quartz JdbcJobStore, so this should be everything you need. All properties supporting by Quartz' jdbc job store are available to you. The only difference is that it uses a datasource in a Spring context.

    Or am I missing something

  3. #3
    Join Date
    Aug 2004
    Location
    Montreal - Canada
    Posts
    46

    Default

    Here is my scheduler configuration:

    Code:
      <bean id="Scheduler" 
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
        <property name="dataSource">
            <ref bean="DBDataSource"/>
        </property>
        <property name="autoStartup"><value>true</value></property>
        <property name="applicationContextSchedulerContextKey"><value>applicationContext</value></property> 
        <property name="waitForJobsToCompleteOnShutdown"><value>true</value></property> 
        <property name="quartzProperties">
          <props>
            <!-- ThreadPool -->
            <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
            <prop key="org.quartz.threadPool.threadCount">5</prop>
            <prop key="org.quartz.threadPool.threadPriority">5</prop>
              <!-- Job store -->
            <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
            <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
            <prop key="org.quartz.jobStore.driverDelegateClass">$&#123;jdbc.quartz.delegateClassName&#125;</prop>
            <prop key="org.quartz.jobStore.useProperties">false</prop>
            <!-- Uncomment the following if you want to use a separate data source -->
            <!-- <prop key="org.quartz.jobStore.dataSource">quartzDS</prop> -->
            <!-- DataSource -->
            <!--
            <prop key="org.quartz.dataSource.quartzDS.driver">$&#123;jdbc.driverClassName&#125;</prop>
            <prop key="org.quartz.dataSource.quartzDS.URL">$&#123;jdbc.url&#125;</prop>
            <prop key="org.quartz.dataSource.quartzDS.user">$&#123;jdbc.username&#125;</prop>
            <prop key="org.quartz.dataSource.quartzDS.password">$&#123;jdbc.password&#125;</prop>
            <prop key="org.quartz.dataSource.quartzDS.maxConnections">5</prop>
            -->
            <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM &#123;0&#125;LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
            <!-- Plugins -->
            <prop key="org.quartz.plugin.shutdownhook.class">org.quartz.plugins.management.ShutdownHookPlugin</prop>
            <prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop>
            <prop key="org.quartz.plugin.triggHistory.class">org.quartz.plugins.history.LoggingTriggerHistoryPlugin</prop>
            <prop key="org.quartz.plugin.triggHistory.triggerFiredMessage">Trigger &#123;1&#125;.&#123;0&#125; fired job &#123;6&#125;.&#123;5&#125; at&#58; &#123;4, date, HH&#58;mm&#58;ss MM/dd/yyyy&#125;</prop>
            <prop key="org.quartz.plugin.triggHistory.triggerCompleteMessage">Trigger &#123;1&#125;.&#123;0&#125; completed firing job &#123;6&#125;.&#123;5&#125; at &#123;4, date, HH&#58;mm&#58;ss MM/dd/yyyy&#125; with resulting trigger instruction code&#58; &#123;9&#125;</prop>
          </props>
        </property>
        <property name="triggers">
          <list>
            <ref local="MyTrigger1"/>
            <ref local="MyTrigger2"/>
          </list>
        </property>
      </bean>
    Christophe

  4. #4
    Join Date
    Aug 2004
    Posts
    6

    Default Thanks

    Looks like that might do it, thanks. I will give it a try. Guess I was looking for a way to do it all with beans, but the properties idea is a good one.

  5. #5

    Default Using Quartz inside SpringFramework

    Sorry if this is something I am just missing in the docs

    I want to configure a Quartz Scheulder from my spring.xml . My requirement is user saves an event in the database ,and based on the time that is mention in the event(i.e stored in the database) ,sheduler should start the job on that time.
    May i know how i can perform this...please let me know if i need to refer any other docs.

    Thanks in advance

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    I can provide no examples. But conceptually you could define a Job that regularly checks the database for new event entries. If one is found, a new Job could be scheduled based on that event's time entry.

    Hope that helps,
    Andreas

  7. #7

    Default Using Quartz inside SpringFramework'

    Thanks Andreas,
    But in this case checking for new event in the database each and every time might lead to performance issue. Is there any thing i.e plugin or utility that does this part of task, intracting with database to check for new events.
    By the way i have a small confusion about the JDBCJobStore ,my understanding of this is just stores the jobs,triggers etc.. in the database or is that it fires the job based on the schedule .

    Can you please clarify this.

    Thanks in advance
    Ramana

  8. #8
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by venkatramana
    But in this case checking for new event in the database each and every time might lead to performance issue.
    That depends on the frequency of checks and database contention. I would test that approach before dismissing it, because it should be the most easy to implement.

    Quote Originally Posted by venkatramana
    Is there any thing i.e plugin or utility that does this part of task, intracting with database to check for new events.
    One thing to realize a "push" model would be to utilize database triggers. Those could be used to inform your application about a new event. However, how to establich interaction between your database trigger and your application depends on the capabilities of your database. You have to consult your database's documentation to find out more.

    Besides that: Are you in control of the process creating the events in the database? In that case you could add a notification logic there (maybe via messaging) so that you get informed of new events.


    Quote Originally Posted by venkatramana
    By the way i have a small confusion about the JDBCJobStore ,my understanding of this is just stores the jobs,triggers etc.. in the database or is that it fires the job based on the schedule.
    I would say that JDBCJobStore is solely dedicated to storage issues.

    Regards,
    Andreas

  9. #9

    Default Using Quartz inside SpringFramework'

    thanks Andreas,

    if JDBCJobStore is solely dedicated to storage .then what is the use of it ,i mean storing the jobs and triggers in database, which way it will help us.

    Thanks in advance
    ramana

Similar Threads

  1. Replies: 3
    Last Post: May 4th, 2010, 03:23 AM
  2. Migrating to new version of Quartz
    By ramkris in forum Container
    Replies: 4
    Last Post: Nov 15th, 2005, 02:51 AM
  3. Quartz - Statefull Jobs
    By nandhusriram in forum Container
    Replies: 1
    Last Post: Sep 7th, 2005, 01:11 PM
  4. Quartz question
    By kuns in forum Container
    Replies: 3
    Last Post: Jul 11th, 2005, 03:03 PM
  5. Quartz - Couldn't retrieve job
    By newreaders in forum Container
    Replies: 4
    Last Post: Jun 1st, 2005, 08:12 PM

Posting Permissions

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