You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/09/24 17:34:20 UTC
[4/6] git commit: adjusting sleep
adjusting sleep
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fd6b73f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fd6b73f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fd6b73f3
Branch: refs/heads/two-dot-o-candidate
Commit: fd6b73f33cbbb633f2fab517a9f6761616f341ab
Parents: 15b6651
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 23 18:52:35 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 23 18:53:35 2014 -0600
----------------------------------------------------------------------
.../services/notifications/QueueListener.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fd6b73f3/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 65d99be..e7ba00e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -35,7 +35,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
public class QueueListener {
- public static int MAX_CONSECUTIVE_FAILS = 10;
+ public static int MAX_CONSECUTIVE_FAILS = 10000;
public static final long MESSAGE_TRANSACTION_TIMEOUT = 60 * 5 * 1000;
@@ -180,11 +180,12 @@ public class QueueListener {
LOG.info("QueueListener: sent batch {} messages duration {} ms", messages.size(),System.currentTimeMillis() - now);
if(sleepBetweenRuns > 0) {
+ LOG.info("QueueListener: sleep between rounds...sleep...{}", sleepBetweenRuns);
Thread.sleep(sleepBetweenRuns);
}
}
else{
- LOG.info("QueueListener: no messages...sleep...", results.size());
+ LOG.info("QueueListener: no messages...sleep...{}", sleepWhenNoneFound);
Thread.sleep(sleepWhenNoneFound);
}
//send to the providers
@@ -192,13 +193,11 @@ public class QueueListener {
}catch (Exception ex){
LOG.error("failed to dequeue",ex);
try {
- Thread.sleep(sleepWhenNoneFound);
+ long sleeptime = sleepWhenNoneFound*(consecutiveExceptions.get()+1);
+ LOG.info("sleeping due to failures {} ms", sleeptime);
+ Thread.sleep(sleeptime);
}catch (InterruptedException ie){
- LOG.info("sleep interupted");
- }
- if(consecutiveExceptions.getAndIncrement() > MAX_CONSECUTIVE_FAILS){
- LOG.error("killing message listener; too many failures");
- break;
+ LOG.info("sleep interrupted");
}
}
}