From 0b778c328001d25b3118450c0bfabb3e0b918971 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 10 Sep 2008 18:15:25 +0000 Subject: Cluster support for copying shared broker state to new members. cluster/DumpClient: Copies broker shared state to a new broker via AMQP. broker/*Registry, Queue, QueueBindings: Added iteration functions for DumpClient broker/SemanticState.cpp: Allow DumpClient to sidestep setting of delivery-properties.exchange. client/Connection.h: Added Connection::open(Url) overload. client/SessionImpl: Added send(AMQBody, FrameSet) overload for forwarding broker messages. tests/cluster_test.cpp: Added test for DumpClient copying shared state between brokers. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@693918 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/Connection.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'cpp/src/qpid/client/Connection.cpp') diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index 6572794516..e19cfea059 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/cpp/src/qpid/client/Connection.cpp @@ -23,6 +23,7 @@ #include "Message.h" #include "SessionImpl.h" #include "SessionBase_0_10Access.h" +#include "qpid/Url.h" #include "qpid/log/Logger.h" #include "qpid/log/Options.h" #include "qpid/log/Statement.h" @@ -47,6 +48,37 @@ Connection::Connection() : channelIdCounter(0), version(framing::highestProtocol Connection::~Connection(){ } +void Connection::open( + const Url& url, + const std::string& uid, const std::string& pwd, + const std::string& vhost, + uint16_t maxFrameSize) +{ + if (url.empty()) + throw Exception(QPID_MSG("Attempt to open URL with no addresses.")); + Url::const_iterator i = url.begin(); + do { + const TcpAddress* tcp = i->get(); + 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); + break; + } + catch (const Exception& e) { + if (i == url.end()) throw; + } + } + } while (i != url.end()); +} + void Connection::open( const std::string& host, int port, const std::string& uid, const std::string& pwd, -- cgit v1.2.1