From 842bc4556204ea0ea4f048ed13bccb3545d22e76 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 17 Oct 2008 16:45:24 +0000 Subject: 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 --- qpid/cpp/examples/failover/direct_producer.cpp | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/examples/failover/direct_producer.cpp') 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; } -- cgit v1.2.1