summaryrefslogtreecommitdiff
path: root/qpid/cpp/examples/messaging
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-10-21 22:04:51 +0000
committerKim van der Riet <kpvdr@apache.org>2013-10-21 22:04:51 +0000
commit888581cb9781259073d190edede25e6253ec7dd9 (patch)
treeca719eb54a498aebb5c59c527b08178491e4ad4c /qpid/cpp/examples/messaging
parent6d5d782b504677fcc4392086cb628dbbb79c800a (diff)
downloadqpid-python-888581cb9781259073d190edede25e6253ec7dd9.tar.gz
QPID-4984: WIP - Merge from trunk r.1534385.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/linearstore@1534394 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/messaging')
-rw-r--r--qpid/cpp/examples/messaging/hello_world.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/qpid/cpp/examples/messaging/hello_world.cpp b/qpid/cpp/examples/messaging/hello_world.cpp
index 86342b3c47..a868a64b5e 100644
--- a/qpid/cpp/examples/messaging/hello_world.cpp
+++ b/qpid/cpp/examples/messaging/hello_world.cpp
@@ -33,9 +33,9 @@ int main(int argc, char** argv) {
std::string broker = argc > 1 ? argv[1] : "localhost:5672";
std::string address = argc > 2 ? argv[2] : "amq.topic";
std::string connectionOptions = argc > 3 ? argv[3] : "";
-
- Connection connection(broker, connectionOptions);
+
try {
+ Connection connection(broker, connectionOptions);
connection.open();
Session session = connection.createSession();
@@ -47,12 +47,11 @@ int main(int argc, char** argv) {
Message message = receiver.fetch(Duration::SECOND * 1);
std::cout << message.getContent() << std::endl;
session.acknowledge();
-
+
connection.close();
return 0;
} catch(const std::exception& error) {
std::cerr << error.what() << std::endl;
- connection.close();
- return 1;
+ return 1;
}
}