summaryrefslogtreecommitdiff
path: root/qpid/cpp/examples/messaging/drain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/examples/messaging/drain.cpp')
-rw-r--r--qpid/cpp/examples/messaging/drain.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/qpid/cpp/examples/messaging/drain.cpp b/qpid/cpp/examples/messaging/drain.cpp
index bd18fd3884..38f6bdbb98 100644
--- a/qpid/cpp/examples/messaging/drain.cpp
+++ b/qpid/cpp/examples/messaging/drain.cpp
@@ -93,8 +93,8 @@ int main(int argc, char** argv)
{
Options options(argv[0]);
if (options.parse(argc, argv)) {
+ Connection connection(options.connectionOptions);
try {
- Connection connection(options.connectionOptions);
connection.open(options.url);
Session session = connection.newSession();
Receiver receiver = session.createReceiver(options.address);
@@ -116,6 +116,7 @@ int main(int argc, char** argv)
return 0;
} catch(const std::exception& error) {
std::cout << error.what() << std::endl;
+ connection.close();
}
}
return 1;