Could we maintain order of messages in AWS-IoT at subscriber end?
Asked Answered
S

3

7

We have created a thing using AWS-IoT service. We have created a topic in that particular thing. Subscriber has subscribed to that topic and publisher is sending messages to that topic.

Below is the publisher messaging order:

message 0
message 1
message 2
message 3
message 4 

At the subscriber end the sequence of messages is not maintained. It's showing like this:

message 0
message 1
message 4
message 2
message 3
Soricine answered 4/10, 2017 at 6:54 Comment(0)
C
4

True, in AWS IoT, the message broker does not guarantee order while they deliver messages to the devices.

The reason being that in a typical distributed systems architecture, a single message from the publisher to the subscriber shall take multiple paths to ensure that the system is highly available and scalable. In the case of AWS IoT, the Device Gateway supports the publisher subscriber messaging pattern and enables scalable, low-latency, and low-overhead communication.

However, based on the type of use case, there are many possible solutions that can be worked out. There should be a logic such that the publishers themselves shall do the co-ordination. One generic or simple approach could be that a sequence number addition at the device side should be sufficient to handle the ordering of the messages between publisher and subscriber. On the receiver, a logic to process or discard based on checking of the ordering based on sequence number should be helpful.

Crucifix answered 22/2, 2020 at 10:16 Comment(0)
N
0

As written in the documentation of AWS

The message broker does not guarantee the order in which messages and ACK are received.

Naraka answered 9/1, 2019 at 12:15 Comment(0)
B
0

I guess its too late to answer to this question but I'll still go ahead so others facing this issue can have a work around. I faced a similar scenario and I did the following to make sure that the order is maintained.

  1. I added sequence ID or timestamp to the payload sent to the broker from my iot device (can be any kind of client)
  2. I then configured the IoT rules engine (add actions) to send the messages directly to DynamoDB where the data was automatically stored in a sorted manner (needs to be configured to sort by seqID).
  3. Then I used Lambda to pull out the data from DynamoDB for my further workflow but you can use whatever service according to yours.
Bowman answered 20/2, 2020 at 5:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.