From 610b5bf2be6684bc056cde1d23eaafa8bfc0c4c2 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 4 Feb 2015 10:25:06 +0000
Subject: [PATCH] Task #7432: Close connections to guarantee delivery of
 pending sends/acks/etc

---
 LCS/MessageBus/src/MsgBus.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/LCS/MessageBus/src/MsgBus.cc b/LCS/MessageBus/src/MsgBus.cc
index 933a6df2d50..03ec2fa6068 100644
--- a/LCS/MessageBus/src/MsgBus.cc
+++ b/LCS/MessageBus/src/MsgBus.cc
@@ -44,6 +44,13 @@ namespace LOFAR {
     if (itsNrMissingACKs) {
 //      LOG_ERROR_STR("Queue " << itsQueueName << " on broker " << itsBrokerName << " has " << itsNrMissingACKs << " messages not ACK'ed ");
 	}
+
+    try {
+      // Make sure all requests are finished
+      itsConnection.close();
+    } catch(const qpid::types::Exception &ex) {
+      LOG_FATAL_STR("Exception in destructor, cannot guarantee message delivery: " << ex.what());
+    }
   }
 
   bool FromBus::getMessage(LOFAR::Message &msg, double timeout) // timeout 0.0 means blocking
@@ -109,8 +116,16 @@ namespace LOFAR {
   } catch(const qpid::types::Exception &ex) {
     THROW(MessageBusException, ex.what());
   }
+
   ToBus::~ToBus(void)
   {
+
+    try {
+      // Make sure all requests are finished
+      itsConnection.close();
+    } catch(const qpid::types::Exception &ex) {
+      LOG_FATAL_STR("Exception in destructor, cannot guarantee message delivery: " << ex.what());
+    }
   }
 
   void ToBus::send(const std::string &msg)
-- 
GitLab