From commits-return-17063-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Fri Sep 23 18:48:43 2011 Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CF9A59074 for ; Fri, 23 Sep 2011 18:48:43 +0000 (UTC) Received: (qmail 65332 invoked by uid 500); 23 Sep 2011 18:48:43 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 65302 invoked by uid 500); 23 Sep 2011 18:48:43 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 65295 invoked by uid 99); 23 Sep 2011 18:48:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Sep 2011 18:48:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Sep 2011 18:48:40 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 79CD923888FD for ; Fri, 23 Sep 2011 18:48:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1174951 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java Date: Fri, 23 Sep 2011 18:48:19 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110923184819.79CD923888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Fri Sep 23 18:48:19 2011 New Revision: 1174951 URL: http://svn.apache.org/viewvc?rev=1174951&view=rev Log: fix for: https://issues.apache.org/jira/browse/AMQ-3031 Don't use the scheduleAtFixedRate method in our scheduler as we don't really have a need for real time task execution, just use the fixed delay scheduler so that jobs don't stack up. Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java?rev=1174951&r1=1174950&r2=1174951&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/thread/Scheduler.java Fri Sep 23 18:48:19 2011 @@ -23,25 +23,25 @@ import org.apache.activemq.util.ServiceS import org.apache.activemq.util.ServiceSupport; /** - * + * */ -public final class Scheduler extends ServiceSupport { +public final class Scheduler extends ServiceSupport { private final String name; - private Timer timer; + private Timer timer; private final HashMap timerTasks = new HashMap(); - + public Scheduler (String name) { this.name = name; } - + public void executePeriodically(final Runnable task, long period) { - TimerTask timerTask = new SchedulerTimerTask(task); - timer.scheduleAtFixedRate(timerTask, period, period); + TimerTask timerTask = new SchedulerTimerTask(task); + timer.schedule(timerTask, period, period); timerTasks.put(task, timerTask); } /* - * execute on rough schedual based on termination of last execution. There is no + * execute on rough schedule based on termination of last execution. There is no * compensation (two runs in quick succession) for delays */ public synchronized void schedualPeriodically(final Runnable task, long period) { @@ -49,9 +49,9 @@ public final class Scheduler extends Ser timer.schedule(timerTask, period, period); timerTasks.put(task, timerTask); } - + public synchronized void cancel(Runnable task) { - TimerTask ticket = timerTasks.remove(task); + TimerTask ticket = timerTasks.remove(task); if (ticket != null) { ticket.cancel(); timer.purge();//remove cancelled TimerTasks @@ -59,10 +59,10 @@ public final class Scheduler extends Ser } public synchronized void executeAfterDelay(final Runnable task, long redeliveryDelay) { - TimerTask timerTask = new SchedulerTimerTask(task); + TimerTask timerTask = new SchedulerTimerTask(task); timer.schedule(timerTask, redeliveryDelay); } - + public void shutdown() { timer.cancel(); } @@ -70,7 +70,7 @@ public final class Scheduler extends Ser @Override protected synchronized void doStart() throws Exception { this.timer = new Timer(name, true); - + } @Override @@ -78,7 +78,7 @@ public final class Scheduler extends Ser if (this.timer != null) { this.timer.cancel(); } - + } public String getName() {