Throttling OfflineMsgStore's messages when WebSocket looses connection with UpdatePropertyValues svc
I read this article: How to insert past-data to a Thing?
I want to handle Offline messages in a specific way when TW agent's WebSocket looses connection to TW server for some amount of time.
I have these requirements:
- Real-time data cannot be delayed by historical data. Real-time data takes priority.
- Cached data cannot be sent all at once but must be throttled.
I have these settings that configure Message Queue size to 1GB.
config.ThrowOnOfflineMesssageSave = true; config.OfflineMsgQueueSize = 1048576; //16384 default config.OfflineMsgStoreDir = "C:\OfflineMsgStoreFolder";
Questions:
1. When WebSocket connection gets established again and we have a huge number of messages in the Message queue (let's say full 1GB) and we also have the latest collection of updated properties in the memory, will all historical messages in the queue be propagated the TW server before the latest update is sent?
2. Is there a way to first sent the latest change and send historical data later?
3. Is there a way to control the speed of sending historical data so it doesn't affect outbound Internet traffic, i.e. can we throttle that tragic?
4.I am wondering if I can turn turn off offline message store? Maybe OfflineMsgQueueSize=0 would to the trick.
I would expect some settings to control that. Then I can do some custom solution to satisfy requirements?
5. If I am able to do custom offline message handling can I use VirtualThing.getPendingPropertyUpdates() method to obtain the list of PropetyValue changes, write it (serialize it to a local disk) and then clear/drain PropertyValueList (by calling drainPendingPropertyUpdates() to release Memory usage)?
Then I could use manual push in a controlled way to sent historical data using UpdatePropertyValues service to re-create history (as explained in How to insert past-data to a Thing?)
However the number of PropertyValues can be different each during each scanning cycle on the agent so how can I handle various number of properties I have in each update?
I would like to reduce the number of properties I am sending to the server.
6. Any other recommendation on how to do custom offline message handling?
Can you interact with saved offline messages via TW SDK API and handle sending to TW server in custom way by preventing automatic sending, i.e. when WS connection gets established once again, can I intercept that event and ready messages from offline message store and send them slowly over time, but in the meantime I want to send the latest updates multiple times so I don't loose visibility on how Properties change at the current movement.
Thanks
Rad

