Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3393340
D3833.id11867.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3833.id11867.diff
View Options
diff --git a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
--- a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
+++ b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
@@ -155,6 +155,14 @@
}
const std::string clientDeviceID = sessionItem->getDeviceID();
const std::string messageID = tools::generateUUID();
+
+ const database::MessageItem message(
+ messageID,
+ clientDeviceID,
+ request->todeviceid(),
+ request->payload(),
+ "");
+ database::DatabaseManager::getInstance().putMessageItem(message);
if (!AmqpManager::getInstance().send(
messageID,
clientDeviceID,
@@ -199,6 +207,21 @@
}
const std::string clientDeviceID = sessionItem->getDeviceID();
DeliveryBrokerMessage messageToDeliver;
+
+ std::vector<std::shared_ptr<database::MessageItem>> messagesFromDatabase =
+ database::DatabaseManager::getInstance().findMessageItemsByReceiver(
+ clientDeviceID);
+ for (auto &messageFromDatabase : messagesFromDatabase) {
+ tunnelbroker::GetResponse response;
+ response.set_fromdeviceid(messageFromDatabase->getFromDeviceID());
+ response.set_payload(messageFromDatabase->getPayload());
+ if (!writer->Write(response)) {
+ throw std::runtime_error(
+ "gRPC: 'Get' writer error on sending data to the client");
+ }
+ database::DatabaseManager::getInstance().removeMessageItem(
+ messageFromDatabase->getMessageID());
+ }
while (1) {
messageToDeliver = DeliveryBroker::getInstance().pop(clientDeviceID);
tunnelbroker::GetResponse response;
@@ -210,6 +233,8 @@
}
comm::network::AmqpManager::getInstance().ack(
messageToDeliver.deliveryTag);
+ database::DatabaseManager::getInstance().removeMessageItem(
+ messageToDeliver.messageID);
if (DeliveryBroker::getInstance().isEmpty(clientDeviceID)) {
DeliveryBroker::getInstance().erase(clientDeviceID);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 1:17 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605091
Default Alt Text
D3833.id11867.diff (2 KB)
Attached To
Mode
D3833: [services] Tunnelbroker - Put and get messages from database in grpc handler
Attached
Detach File
Event Timeline
Log In to Comment