IoT Core Message Ordering

0

I am working on IoT project which require message order. Example I am monitoring elevator in the building. So when elevator moves from floor 1 to 10, I will receive MQTT message for each floor. My problem is: if Broker is not guarantee message sequence based on ACK, my simulation/consumer might get flor number as 1,2,3,[9],4,5,6,7,8,10. So this is kind of not real time monitoring. If this is the case what will be good solution to use instead of IoT Core? Should I go directly with AWS Kinesis Data Stream or any other alternative?

asked a year ago561 views
1 Answer
0
Accepted Answer

Hi Ozy, the solution depends on how long your consumer is willing to wait for out-of-order messages. E.g in your elevator example, if your elevator moves from floor 1 to 5 and your consumer receives events 1,2,3,5 .... 1h ... 4. Are you ok to wait for 1h before message 4 is unstuck and continue processing message 5? I advise to develop a consumer that can handle out-of-order messages, it makes the solution more robust.

That said, if you use a QoS1 on your client and the events are spaced (in the elevator example several seconds), the chance to get a message out-of-order from one elevator are very low. And if you add some kind of sequence number to the message payload {floor:one , seq:100} , {floor:two, seq:101},{floor:three, seq:102},{floor:five, seq:104} on the device side, you can detect an out-of-order message at the consumer side and trigger exception logic.

profile pictureAWS
EXPERT
Jan_B
answered a year ago
  • Jan_B, thanks for the explanation and no 1h even 10 sec delay is not acceptable. I have same kind of solution in mind to cover the unordered message as you explained perfectly(message is going to be QoS1 and will have timestamp and sequence number). Now I should either go with some custom handling : this depends on how often this problem will happen, is it %1 or less or %10 or more. Because I will have many moving targets and real time is very crucial. Or I can go with streaming to from device directly and get everything in order. I do have a question on the broker message delivery to subscriber but will ask that as separate question to keep the scope here, thank you for your time

    And thank you for explanation instead of just copy/pasting the document link :) AWS should know when we ask question here we already know where to find these docs, question is when we have done all these and need some experts idea instead of being broker to documents :)

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions