Repository: qpid-jms
Updated Branches:
  refs/heads/master a83f64faf -> f138997bf


Look for the connection opened failed property and wait for close if it
is present.  

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

Branch: refs/heads/master
Commit: f138997bf83c95730ab45526fae908f2457fde8f
Parents: a83f64f
Author: Timothy Bish <[email protected]>
Authored: Tue Mar 10 15:11:01 2015 -0400
Committer: Timothy Bish <[email protected]>
Committed: Tue Mar 10 15:11:01 2015 -0400

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpConnection.java  | 42 +++++++++++---------
 .../provider/amqp/AmqpConnectionProperties.java | 28 +++++++++++++
 2 files changed, 52 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f138997b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
index 7cc4a87..7dd7c16 100644
--- 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
@@ -115,25 +115,31 @@ public class AmqpConnection extends 
AmqpAbstractResource<JmsConnectionInfo, Conn
     @Override
     protected void doOpenCompletion() {
         properties.initialize(getEndpoint().getRemoteOfferedCapabilities(), 
getEndpoint().getRemoteProperties());
-        connectionSession.open(new AsyncResult() {
 
-            @Override
-            public boolean isComplete() {
-                return connectionSession.isOpen();
-            }
-
-            @Override
-            public void onSuccess() {
-                LOG.debug("{} is now open: ", AmqpConnection.this);
-                opened();
-            }
-
-            @Override
-            public void onFailure(Throwable result) {
-                LOG.debug("AMQP Connection Session failed to open.");
-                failed(IOExceptionSupport.create(result));
-            }
-        });
+        // If the remote reports that the connection attempt failed then we 
can assume a
+        // close follows so do nothing and wait so a proper error can be 
constructed from
+        // the information in the remote close.
+        if (!properties.isConnectionOpenFailed()) {
+            connectionSession.open(new AsyncResult() {
+
+                @Override
+                public boolean isComplete() {
+                    return connectionSession.isOpen();
+                }
+
+                @Override
+                public void onSuccess() {
+                    LOG.debug("{} is now open: ", AmqpConnection.this);
+                    opened();
+                }
+
+                @Override
+                public void onFailure(Throwable result) {
+                    LOG.debug("AMQP Connection Session failed to open.");
+                    failed(IOExceptionSupport.create(result));
+                }
+            });
+        }
     }
 
     public void processSaslAuthentication() {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/f138997b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
index ca24f32..f6ed263 100644
--- 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
@@ -37,10 +37,12 @@ public class AmqpConnectionProperties {
     public static final Symbol ANONYMOUS_RELAY = 
Symbol.valueOf("ANONYMOUS-RELAY");
     public static final Symbol QUEUE_PREFIX = Symbol.valueOf("queue-prefix");
     public static final Symbol TOPIC_PREFIX = Symbol.valueOf("topic-prefix");
+    public static final Symbol CONNECTION_OPEN_FAILED = 
Symbol.valueOf("amqp:connection-establishment-failed");
 
     private final JmsConnectionInfo connectionInfo;
 
     private boolean anonymousRelaySupported = false;
+    private boolean connectionOpenFailed = false;
 
     /**
      * Creates a new instance of this class with default values read from the
@@ -97,6 +99,11 @@ public class AmqpConnectionProperties {
             }
         }
 
+        if (properties.containsKey(CONNECTION_OPEN_FAILED)) {
+            LOG.trace("Remote sent Connection Establishment Failed marker.");
+            connectionOpenFailed = true;
+        }
+
         // TODO - Inspect properties for any other configuration options
     }
 
@@ -150,4 +157,25 @@ public class AmqpConnectionProperties {
     public void setTopicPrefix(String topicPrefix) {
         connectionInfo.setTopicPrefix(topicPrefix);
     }
+
+    /**
+     * Returns true if the remote connection marked the open response as being 
in
+     * a failed state which implies that a close follows.
+     *
+     * @return the connectionOpenFailed value.
+     */
+    public boolean isConnectionOpenFailed() {
+        return connectionOpenFailed;
+    }
+
+    /**
+     * Sets the state of the connection open failed flag.  When this flag is 
set
+     * true it implies that the open response will have a close response to 
follow.
+     *
+     * @param connectionOpenFailed
+     *        the connectionOpenFailed value to use for these properties.
+     */
+    public void setConnectionOpenFailed(boolean connectionOpenFailed) {
+        this.connectionOpenFailed = connectionOpenFailed;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to