diff options
author | Gordon Sim <gsim@apache.org> | 2008-11-07 14:08:29 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-11-07 14:08:29 +0000 |
commit | 53247faba484516d9c468b7ae7f514f32541295a (patch) | |
tree | 2a823dcf2f292479ba122a25a1fadec3837f9562 /qpid/cpp/examples/failover/resuming_receiver.cpp | |
parent | 0e0d76bedfb1f369ab0a71a62c931c13d66e0b7e (diff) | |
download | qpid-python-53247faba484516d9c468b7ae7f514f32541295a.tar.gz |
* Added some doxygen comments for FailoverManager
* Added means for application to alter the order in which urls are tried (or indeed the list of urls to try)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@712127 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/failover/resuming_receiver.cpp')
-rw-r--r-- | qpid/cpp/examples/failover/resuming_receiver.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/qpid/cpp/examples/failover/resuming_receiver.cpp b/qpid/cpp/examples/failover/resuming_receiver.cpp index 3c1df92ed1..d1886ce861 100644 --- a/qpid/cpp/examples/failover/resuming_receiver.cpp +++ b/qpid/cpp/examples/failover/resuming_receiver.cpp @@ -35,13 +35,16 @@ using namespace qpid::framing; using namespace std; -class Listener : public MessageListener, public FailoverManager::Command +class Listener : public MessageListener, + public FailoverManager::Command, + public FailoverManager::ReconnectionStrategy { public: Listener(); void received(Message& message); void execute(AsyncSession& session, bool isRetry); void check(); + void editUrlList(std::vector<Url>& urls); private: Subscription subscription; uint count; @@ -90,14 +93,23 @@ void Listener::execute(AsyncSession& session, bool isRetry) subs.run(); } +void Listener::editUrlList(std::vector<Url>& urls) +{ + /** + * A more realistic algorithm would be to search through the list + * for prefered hosts and ensure they come first in the list. + */ + if (urls.size() > 1) std::rotate(urls.begin(), urls.begin() + 1, urls.end()); +} + int main(int argc, char ** argv) { ConnectionSettings settings; if (argc > 1) settings.host = argv[1]; if (argc > 2) settings.port = atoi(argv[2]); - FailoverManager connection(settings); Listener listener; + FailoverManager connection(settings, &listener); try { connection.execute(listener); |