diff options
| author | Alan Conway <aconway@apache.org> | 2008-10-17 16:45:24 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-10-17 16:45:24 +0000 |
| commit | 842bc4556204ea0ea4f048ed13bccb3545d22e76 (patch) | |
| tree | 7f0fa62ff83d9705808a11083141aec00eeaad26 /qpid/cpp/examples/failover/direct_producer.cpp | |
| parent | 3104d778e1352e9a3a142d8c133a115c847360c2 (diff) | |
| download | qpid-python-842bc4556204ea0ea4f048ed13bccb3545d22e76.tar.gz | |
QPID-1367 Mick Goulish: improvements to client-side failover.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@705668 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/failover/direct_producer.cpp')
| -rw-r--r-- | qpid/cpp/examples/failover/direct_producer.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/qpid/cpp/examples/failover/direct_producer.cpp b/qpid/cpp/examples/failover/direct_producer.cpp index 1bee56e164..513971197e 100644 --- a/qpid/cpp/examples/failover/direct_producer.cpp +++ b/qpid/cpp/examples/failover/direct_producer.cpp @@ -36,12 +36,13 @@ using namespace std; int main ( int argc, char ** argv) { + const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; int count = argc>3 ? atoi(argv[3]) : 30; - int delayMs = argc>4 ? atoi(argv[4]) : 1000; string program_name = "PRODUCER"; + try { FailoverConnection connection; FailoverSession * session; @@ -49,14 +50,23 @@ main ( int argc, char ** argv) connection.open ( host, port ); session = connection.newSession(); + bool report = true; int sent = 0; while ( sent < count ) { + message.getDeliveryProperties().setRoutingKey("routing_key"); - std::cout << "sending message " - << sent - << " of " - << count - << ".\n"; + + + if ( count > 1000 ) + report = !(sent % 1000); + + if ( report ) + { + std::cout << "sending message " + << sent + << ".\n"; + } + stringstream message_data; message_data << sent; message.setData(message_data.str()); @@ -70,12 +80,12 @@ main ( int argc, char ** argv) 0, message ); - usleep ( 1000*delayMs ); + ++ sent; } message.setData ( "That's all, folks!" ); - /* MICK FIXME + /* FIXME mgoulish 16 Oct 08 session.messageTransfer ( arg::content=message, arg::destination="amq.direct" ); @@ -88,10 +98,17 @@ main ( int argc, char ** argv) session->sync(); connection.close(); + std::cout << program_name + << " sent " + << sent + << " messages.\n"; + std::cout << program_name << ": " << " completed without error." << std::endl; return 0; } catch(const std::exception& error) { std::cout << program_name << ": " << error.what() << std::endl; + std::cout << program_name << "Exiting.\n"; + return 1; } return 1; } |
