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/declare_queues.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/declare_queues.cpp')
-rw-r--r-- | qpid/cpp/examples/failover/declare_queues.cpp | 73 |
1 files changed, 23 insertions, 50 deletions
diff --git a/qpid/cpp/examples/failover/declare_queues.cpp b/qpid/cpp/examples/failover/declare_queues.cpp index 14e4a1e3cb..a677870c53 100644 --- a/qpid/cpp/examples/failover/declare_queues.cpp +++ b/qpid/cpp/examples/failover/declare_queues.cpp @@ -19,67 +19,40 @@ * */ -#include <qpid/client/FailoverConnection.h> +#include <qpid/client/FailoverManager.h> #include <qpid/client/Session.h> +#include <qpid/Exception.h> -#include <unistd.h> #include <cstdlib> #include <iostream> -#include <fstream> using namespace qpid::client; -using namespace qpid::framing; - using namespace std; - - - -int -main ( int argc, char ** argv) +int main(int argc, char ** argv) { - if ( argc < 3 ) - { - std::cerr << "Usage: ./declare_queues host cluster_port_file_name\n"; - std::cerr << "i.e. for host: 127.0.0.1\n"; - exit(1); - } - - const char * host = argv[1]; - int port = atoi(argv[2]); - - - try - { - FailoverConnection connection; - FailoverSession * session; - - connection.open ( host, port ); - session = connection.newSession(); - - session->queueDeclare ( "message_queue"); + ConnectionSettings settings; + if (argc > 1) settings.host = argv[1]; + if (argc > 2) settings.port = atoi(argv[2]); + + FailoverManager connection(settings); + try { + bool complete = false; + while (!complete) { + Session session = connection.connect().newSession(); + try { + session.queueDeclare(arg::queue="message_queue"); + complete = true; + } catch (const qpid::TransportFailure&) {} + } + connection.close(); + return 0; + } catch (const std::exception& error) { + std::cout << "Failed:" << error.what() << std::endl; + return 1; + } - /* - session->exchangeBind - ( arg::exchange="amq.direct", - arg::queue="message_queue", - arg::bindingKey="routing_key" - ); - * */ - session->exchangeBind ( "message_queue", - "amq.direct", - "routing_key" - ); - connection.close(); - return 0; - } - catch ( const std::exception& error ) - { - std::cout << error.what() << std::endl; - } - - return 1; } |