有消息发生在飞行时,AWS物联网设备断开连接,并重新连接什么消息、发生在、设备、AWS

2023-09-12 21:31:11 作者:你会腻我何必

我有一个设备(又名东西)成功连接到AWS IOT。该设备将操作使用移动网络非常不可靠的电信环境。这意味着该设备将连接并重新连接频繁,而我的应用程序运行。

I have one device (AKA 'thing') successfully connected to AWS IOT. This device will operate on a very unreliable telco environment using mobile networks. This means that this device will connect and reconnect frequently while my application is running.

我所知道的AWS物联网影子的机制,但需要按顺序消耗我的消息,这意味着我需要的所有信息,而不仅仅是最后的状态。

I'm aware of AWS IOT 'shadow' mechanism, but my messages need to be consumed sequentially, this means that I need all messages, not just the last state.

将与在飞行中的消息和有效载荷发生​​脱节时什么并重新连接事件?

What will happen with the messages and payload in flight during a disconnect and reconnect events?

推荐答案

我正在使用MQTT进行交际假设。既然如此,这段摘录取自 AWS物联网开发者指南:

I'm assuming you are using MQTT for comunication. That being the case, this excerpt is taken from the AWS IoT Developer Guide:

MQTT是一种广泛采用轻量级的消息传递协议设计   受限的设备。欲了解更多信息,请访问MQTT。虽然   AWS的IoT消息代理的实现是基于MQTT V3.1.1,它   从说明书偏离如下:

MQTT is a widely adopted lightweight messaging protocol designed for constrained devices. For more information, go to MQTT. Although the AWS IoT message broker implementation is based on MQTT v3.1.1, it deviates from the specification as follows:   在AWS的IoT,订阅与服务质量(QoS)的话题0表示一消息将被递送零次或多次。可以将消息   传递多次。消息传递多次可能   发送与不同的数据包ID。在这些情况下,DUP标志不为   集。   在AWS物联网不支持发布和订阅具有QoS 2. AWS物联网消息代理不发送PUBACK或SUBACK时的QoS 2   请求。    [...]   在该消息代理不支持持续会话(清洁会话设置为0)。所有会议都被假定为干净会话和   消息不会存储在会话。如果MQTT客户端发送一个   用干净的会话消息属性设置为false,客户端会   被断开。   在极少数情况下,消息代理可以重新发送带有不同的数据包ID相同的逻辑发布的消息。    消息代理不保证该信息和ACK收到的顺序。    In AWS IoT, subscribing to a topic with Quality of Service (QoS) 0 means a message will be delivered zero or more times. A message may be delivered more than once. Messages delivered more than once may be sent with a different packet ID. In these cases, the DUP flag is not set. AWS IoT does not support publishing and subscribing with QoS 2. The AWS IoT message broker does not send a PUBACK or SUBACK when QoS 2 is requested. [...] The message broker does not supports persistent sessions (clean session set to 0). All sessions are assumed to be clean sessions and messages are not stored across sessions. If an MQTT client sends a message with the clean session attribute set to false, the client will be disconnected. On rare occasions, the message broker may resend the same logical publish message with a different packet ID. The message broker does not guarantee the order in which messages and ACK are received.

这表示,AWS物联网MQTT实现不能保证任何特定的顺序,以您的设备的消息。如果你确实需要有一个数据的顺序读取,可以实现某种方式对数据进行分区,并插入元数据在设备中的阴影状态,并有使用AWS物联网规则或AWS拉姆达的数据重新排序。

That said, the AWS IoT MQTT implementation cannot guarantee any specific order to your devices' messages. If you absolutely need to have that data read sequentially, you can implement some way to partition the data and insert metadata in the device shadow state and have that data reordered using a AWS IoT rule or AWS Lambda.