Announcement Announcement Module
Collapse
No announcement yet.
Using Quartz inside SpringFramework Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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>

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment


              • #8
                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.

                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.


                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

                Comment


                • #9
                  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

                  Comment

                  Working...
                  X