activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-4706
Date Wed, 13 Nov 2013 20:19:25 GMT
Updated Branches:
  refs/heads/trunk 7f639a604 -> c55a66692


https://issues.apache.org/jira/browse/AMQ-4706

add setting warnAfterReconnectAttempts to FailoverTransport to log a
warning after every N retries.  A value of <= 0 will disable the
warnings.  

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/c55a6669
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/c55a6669
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/c55a6669

Branch: refs/heads/trunk
Commit: c55a66692126c76b81cfd20c66749e3bf1bb8606
Parents: 7f639a6
Author: Timothy Bish <tabish121@gmai.com>
Authored: Wed Nov 13 15:19:16 2013 -0500
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Wed Nov 13 15:19:16 2013 -0500

----------------------------------------------------------------------
 .../transport/failover/FailoverTransport.java   | 40 +++++++++++++++++++-
 1 file changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/c55a6669/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
index 9a524df..541eaeb 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
@@ -21,8 +21,19 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.InterruptedIOException;
-import java.net.*;
-import java.util.*;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -90,6 +101,7 @@ public class FailoverTransport implements CompositeTransport {
     private int maxReconnectAttempts = INFINITE;
     private int startupMaxReconnectAttempts = INFINITE;
     private int connectFailures;
+    private int warnAfterReconnectAttempts = 10;
     private long reconnectDelay = DEFAULT_INITIAL_RECONNECT_DELAY;
     private Exception connectionFailure;
     private boolean firstConnection = true;
@@ -1089,6 +1101,12 @@ public class FailoverTransport implements CompositeTransport {
                 propagateFailureToExceptionListener(connectionFailure);
                 return false;
             }
+
+            int warnInterval = getWarnAfterReconnectAttempts();
+            if (warnInterval > 0 && (connectFailures % warnInterval) == 0) {
+                LOG.warn("Failed to connect to {} after: {} attempt(s) continuing to retry.",
+                         uris, connectFailures);
+            }
         }
 
         if (!disposed) {
@@ -1411,4 +1429,22 @@ public class FailoverTransport implements CompositeTransport {
         this.nestedExtraQueryOptions = nestedExtraQueryOptions;
     }
 
+    public int getWarnAfterReconnectAttempts() {
+        return warnAfterReconnectAttempts;
+    }
+
+    /**
+     * Sets the number of Connect / Reconnect attempts that must occur before a warn message
+     * is logged indicating that the transport is not connected.  This can be useful when
the
+     * client is running inside some container or service as it give an indication of some
+     * problem with the client connection that might not otherwise be visible.  To disable
the
+     * log messages this value should be set to a value @{code attempts <= 0}
+     *
+     * @param warnAfterReconnectAttempts
+     *      The number of failed connection attempts that must happen before a warning is
logged.
+     */
+    public void setWarnAfterReconnectAttempts(int warnAfterReconnectAttempts) {
+        this.warnAfterReconnectAttempts = warnAfterReconnectAttempts;
+    }
+
 }


Mime
View raw message