Enquiry about MQTT and HTTP

2 次查看(过去 30 天)
Kevin Chia
Kevin Chia 2021-9-18
回答: Shubham 2023-8-30
Was looking through the scenarios between using MQTT and HTTP/REST API.
For REST, it states that I can retreive any historical data, such as data within a defined time range.
So does that mean MQTT won't be able to see historical data? I can see data being stored using MQTT protocol in the MATLAB charts over a period of time, isn't that historical data?
Or isit because those do not have MATLAB Analysis won't be able to see?
(Figure above uses MQTT Protocol)

回答(1 个)

Shubham
Shubham 2023-8-30
Hi Kevin,
In MQTT, the concept of message expiry is supported through the use of the "Message Expiry Interval" property. This property allows you to set a time-to-live (TTL) value for a message, specifying how long the message should be considered valid and deliverable by the MQTT broker.
When publishing a message, you can include the "Message Expiry Interval" property in the MQTT packet. The value of this property is a duration in seconds. If the message is not delivered to the intended recipient within the specified time, the MQTT broker will discard the message and it will not be delivered.
On the subscriber side, if a subscriber connects to a topic and there are messages with expired TTLs, the MQTT broker will not deliver those expired messages to the subscriber. The broker will only deliver messages that are within their TTL duration.
Since MQTT does not inherently store or retain messages beyond their TTL (if set), subscribers connecting to a topic may miss messages that were published before their connection. So that’s why MQTT may not be suitable for retrieving historical data within a defined time range.
Hope this helps. Thank You

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by