summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/client/Connector.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2015-06-17 17:08:55 +0000
committerGordon Sim <gsim@apache.org>2015-06-17 17:08:55 +0000
commit57b80ff868420d23f80d36a1a9eaf630bee48734 (patch)
tree13750bb1fe96d5915e3cc45f3a093ab84d3d6972 /qpid/cpp/src/qpid/client/Connector.cpp
parentb997784b3fc015206cf51c0ca11e9af66893b156 (diff)
downloadqpid-python-57b80ff868420d23f80d36a1a9eaf630bee48734.tar.gz
QPID-6256: Improved handling of protocol version incompatibilities
* 0-10 path no longer hans on open when connecting to a broker not supporting that version * the 'protocol' connection option now supports specifying multiple protocols to try in order (as a coma separated list) * the protocol defaults, i.e. the value assumed if the 'protocol' connection option is not specified, can now be set via the client config file (e.g. protocol-defaults=amqp1.0,amqp0-10) or an environment variable (e.g QPID_PROTOCOL_DEFAULTS=amqp1.0,amqp0-10) * if neither the connection option nor the defaults are specified all valid versions will be tried (currently amqp0-10, then amqp1.0 but this may change in a future version) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1686078 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/client/Connector.cpp')
-rw-r--r--qpid/cpp/src/qpid/client/Connector.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/client/Connector.cpp b/qpid/cpp/src/qpid/client/Connector.cpp
index c71dd9ecb6..af6483c979 100644
--- a/qpid/cpp/src/qpid/client/Connector.cpp
+++ b/qpid/cpp/src/qpid/client/Connector.cpp
@@ -24,6 +24,7 @@
#include "qpid/Exception.h"
#include "qpid/log/Statement.h"
#include "qpid/sys/SecurityLayer.h"
+#include "qpid/framing/ProtocolInitiation.h"
#include <map>
@@ -68,5 +69,26 @@ void Connector::activateSecurityLayer(std::auto_ptr<qpid::sys::SecurityLayer>)
{
}
+bool Connector::checkProtocolHeader(framing::Buffer& in, const framing::ProtocolVersion& version)
+{
+ if (!header) {
+ boost::shared_ptr<framing::ProtocolInitiation> protocolInit(new framing::ProtocolInitiation);
+ if (protocolInit->decode(in)) {
+ header = protocolInit;
+ QPID_LOG(debug, "RECV [" << getIdentifier() << "]: INIT(" << *protocolInit << ")");
+ checkVersion(version);
+ }
+ }
+ return header;
+}
+
+void Connector::checkVersion(const framing::ProtocolVersion& version)
+{
+ if (header && !header->matches(version)){
+ throw ProtocolVersionError(QPID_MSG("Incorrect version: " << *header
+ << "; expected " << version));
+ }
+}
+
}} // namespace qpid::client