activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject [2/2] git commit: Fixes AMQ-4718: Extra options added to a failover/discovery URL that don't map to failover configuration settings, should get passed to the nested URLs.
Date Tue, 10 Sep 2013 16:56:33 GMT
Fixes AMQ-4718: Extra options added to a failover/discovery URL that don't map to failover
configuration settings, should get passed to the nested URLs.

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

Branch: refs/heads/trunk
Commit: 0ff359341c3adc7404b8485ad90a21696da57139
Parents: fd67eef
Author: Hiram Chirino <hiram@hiramchirino.com>
Authored: Tue Sep 10 12:56:25 2013 -0400
Committer: Hiram Chirino <hiram@hiramchirino.com>
Committed: Tue Sep 10 12:56:25 2013 -0400

----------------------------------------------------------------------
 .../transport/failover/FailoverTransport.java   | 40 +++++++++++++-------
 .../failover/FailoverTransportFactory.java      |  6 +++
 2 files changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/0ff35934/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 64d407d..df669bf 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,18 +21,8 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URI;
-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.net.*;
+import java.util.*;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -58,6 +48,7 @@ import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.util.IOExceptionSupport;
 import org.apache.activemq.util.ServiceSupport;
+import org.apache.activemq.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,6 +115,7 @@ public class FailoverTransport implements CompositeTransport {
     private boolean priorityBackup = false;
     private final ArrayList<URI> priorityList = new ArrayList<URI>();
     private boolean priorityBackupAvailable = false;
+    private String nestedExtraQueryOptions;
 
     public FailoverTransport() throws InterruptedIOException {
         brokerSslContext = SslContext.getCurrentSslContext();
@@ -999,7 +991,7 @@ public class FailoverTransport implements CompositeTransport {
                             // We could be starting with a backup and if so we wait to grab
a
                             // URI from the pool until next time around.
                             if (transport == null) {
-                                uri = iter.next();
+                                uri = addExtraQueryOptions(iter.next());
                                 transport = TransportFactory.compositeConnect(uri);
                             }
 
@@ -1180,7 +1172,7 @@ public class FailoverTransport implements CompositeTransport {
                 backups.removeAll(disposedList);
                 disposedList.clear();
                 for (Iterator<URI> iter = backupList.iterator(); !disposed &&
iter.hasNext() && shouldBuildBackups(); ) {
-                    URI uri = iter.next();
+                    URI uri = addExtraQueryOptions(iter.next());
                     if (connectedTransportURI != null && !connectedTransportURI.equals(uri))
{
                         try {
                             SslContext.setCurrentSslContext(brokerSslContext);
@@ -1398,4 +1390,24 @@ public class FailoverTransport implements CompositeTransport {
         }
         return result;
     }
+
+    private URI addExtraQueryOptions(URI uri) {
+        try {
+            if( nestedExtraQueryOptions!=null && !nestedExtraQueryOptions.isEmpty()
) {
+                if( uri.getQuery() == null ) {
+                    uri = URISupport.createURIWithQuery(uri, nestedExtraQueryOptions);
+                } else {
+                    uri = URISupport.createURIWithQuery(uri, uri.getQuery()+"&"+nestedExtraQueryOptions);
+                }
+            }
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
+        }
+        return uri;
+    }
+
+    public void setNestedExtraQueryOptions(String nestedExtraQueryOptions) {
+        this.nestedExtraQueryOptions = nestedExtraQueryOptions;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/0ff35934/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransportFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransportFactory.java
b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransportFactory.java
index c00b8ad..8276b45 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransportFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransportFactory.java
@@ -19,6 +19,7 @@ package org.apache.activemq.transport.failover;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.HashMap;
 import java.util.Map;
 import org.apache.activemq.transport.MutexTransport;
 import org.apache.activemq.transport.ResponseCorrelator;
@@ -70,6 +71,11 @@ public class FailoverTransportFactory extends TransportFactory {
     public FailoverTransport createTransport(Map<String, String> parameters) throws
IOException {
         FailoverTransport transport = new FailoverTransport();
         IntrospectionSupport.setProperties(transport, parameters);
+        try {
+            transport.setNestedExtraQueryOptions(URISupport.createQueryString(parameters));
+        } catch (URISyntaxException e) {
+        }
+        parameters.clear();
         return transport;
     }
 


Mime
View raw message