summaryrefslogtreecommitdiff
path: root/cpp/examples/messaging/spout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/examples/messaging/spout.cpp')
-rw-r--r--cpp/examples/messaging/spout.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/cpp/examples/messaging/spout.cpp b/cpp/examples/messaging/spout.cpp
index cbb6b52b34..4819c6bc00 100644
--- a/cpp/examples/messaging/spout.cpp
+++ b/cpp/examples/messaging/spout.cpp
@@ -156,8 +156,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();
Sender sender = session.createSender(options.address);
@@ -183,6 +183,7 @@ int main(int argc, char** argv)
return 0;
} catch(const std::exception& error) {
std::cout << error.what() << std::endl;
+ connection.close();
}
}
return 1;