diff options
Diffstat (limited to 'cpp/src/qpid/client')
| -rw-r--r-- | cpp/src/qpid/client/Connection.cpp | 21 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connection.h | 12 |
2 files changed, 25 insertions, 8 deletions
diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index 3562df4a74..cc62d724cb 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/cpp/src/qpid/client/Connection.cpp @@ -54,6 +54,15 @@ void Connection::open( const std::string& vhost, uint16_t maxFrameSize) { + ConnectionSettings settings; + settings.username = uid; + settings.password = pwd; + settings.virtualhost = vhost; + settings.maxFrameSize = maxFrameSize; + open(url, settings); +} + +void Connection::open(const Url& url, const ConnectionSettings& settings) { if (url.empty()) throw Exception(QPID_MSG("Attempt to open URL with no addresses.")); Url::const_iterator i = url.begin(); @@ -62,14 +71,10 @@ void Connection::open( i++; if (tcp) { try { - ConnectionSettings settings; - settings.host = tcp->host; - settings.port = tcp->port; - settings.username = uid; - settings.password = pwd; - settings.virtualhost = vhost; - settings.maxFrameSize = maxFrameSize; - open(settings); + ConnectionSettings cs(settings); + cs.host = tcp->host; + cs.port = tcp->port; + open(cs); break; } catch (const Exception& /*e*/) { diff --git a/cpp/src/qpid/client/Connection.h b/cpp/src/qpid/client/Connection.h index ed984ccb42..03631ef56f 100644 --- a/cpp/src/qpid/client/Connection.h +++ b/cpp/src/qpid/client/Connection.h @@ -107,6 +107,18 @@ class Connection const std::string& virtualhost = "/", uint16_t maxFrameSize=65535); /** + * Opens a connection to a broker using a URL. + * If the URL contains multiple addresses, try each in turn + * till connection is successful. + * + * @url address of the broker to connect to. + * + * @param settings used for any settings not provided by the URL. + * Settings provided by the url (e.g. host, port) are ignored. + */ + void open(const Url& url, const ConnectionSettings& settings); + + /** * Opens a connection to a broker. * * @param the settings to use (host, port etc). @see ConnectionSettings. |
