Results 1 to 2 of 2

Thread: Spring 3.0 Scheduled tasks and tomcat have incorrect timings

  1. #1
    Join Date
    Jul 2010
    Posts
    1

    Default Spring 3.0 Scheduled tasks and tomcat have incorrect timings

    I'm trying to run a scheduled task every 10 minutes using the spring scheduler, but when I deploy to tomcat it seems to run at random times. In experimenting I've tried setting the timing to as low as 1 second, but my job seems to run every 8 or 9 seconds. I tried bumping it up to 10 seconds, but it seems to want to run every 30 or seconds. I've tried tomcat 5.5.29 and tomcat6 both are having the same issue. Here's my context.xml:

    Code:
      <context:component-scan base-package="my.worker.package" />
    
      <task:scheduled-tasks scheduler="myScheduler">
        <task:scheduled ref="worker" method="doWork" fixed-rate="1000" />
      </task:scheduled-tasks/>
    
      <task:scheduler id="myScheduler" pool-size="10" />
    My worker class:

    Code:
    @Service
    public class Worker {
      public void doWork() {
        System.out.println(new Date());
      }
    }
    The odd part is it looks like it runs with the correct timing while deploying on startup, but once tomcat gets started then the timing becomes less predictable.

    Thanks for any help or advice.

    Dave

    I'm using the spring 3.0.3 release

  2. #2
    Join Date
    Oct 2009
    Posts
    2

    Default

    Has anyone got a solution for this issue? I have also encountered it using spring 3.0.2 running in Tomcat 6 with jdk 6..

    If I use the task namespace and annotate my beans with, for example, @Scheduled(fixedDelay=60000L), the task runs approximately every 3 minutes as opposed to the 1 minute delay specified.

    If I use the org.springframework.scheduling.concurrent package directly I get the same problem.

    If I use the deprecated classes in the package org.springframework.scheduling.timer (25.7 Using JDK Timer support) I do not get the same problem - the tasks run at the specified rate.

Posting Permissions

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