Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT outbox dequeuing mechanism for esp_mqtt_client_enqueue (IDFGH-13400) #283

Closed
Teesmo opened this issue Aug 6, 2024 · 5 comments
Closed

Comments

@Teesmo
Copy link

Teesmo commented Aug 6, 2024

How does esp_mqtt_client_enqueue dequeue? Is it a FIFO mechanism or a LIFO (or hybrid), I have noticed instances where the most recent data in the queue is published first, or is in conjuction with the (FIFO) queue(i.e temporarily interrupts FIFO dequeuing).

@github-actions github-actions bot changed the title MQTT outbox dequeuing mechanism for esp_mqtt_client_enqueue MQTT outbox dequeuing mechanism for esp_mqtt_client_enqueue (IDFGH-13400) Aug 6, 2024
@euripedesrocha
Copy link
Collaborator

Hi @Teesmo we always push items to the end.
When trying to publish, the first valid occurrence is selected.
For recently enqueued this translates to a FIFO, if we are trying to re transmit messages the one selected is the first that had expired the timeout for retransmission.

So it is always FIFO, but with some different criteria depending on scenario.

Is this behavior affecting your system in some sense?

@Teesmo
Copy link
Author

Teesmo commented Aug 6, 2024

I need a strictly FIFO pipeline because I need data transferred in the order it was extracted from sensors (time-series is crucial here). I need this data not only for time-series but also in order processing, as I have external systems that interact with this system, and can alter the behaviour of this system.
If I understand correctly, the fisrt valid occurrence should be the one that had expired the retransmission timeout. Essentially, this somehow 'guarantees' in order (or FIFO)?
If that's the case, then I think it could work for me. All I need is the FIFO guarantee

@euripedesrocha
Copy link
Collaborator

@Teesmo could you add more information like: QoS of messages, are you using publish or enqueue function?

@Teesmo
Copy link
Author

Teesmo commented Aug 6, 2024

I am using the enqueue function, QoS 1

@euripedesrocha
Copy link
Collaborator

@Teesmo thanks for clarification.
On the way the outbox is managed I believe that you will have the messages sent in the order that they are pushed to the outbox.
You may set the MQTT_MSG_ID_INCREMENTAL to track the order of the messages created.
Can you share how you are detecting the order of messages sent?

If I understand correctly, the fisrt valid occurrence should be the one that had expired the retransmission timeout. Essentially, this somehow 'guarantees' in order (or FIFO)?

From the mqtt client we are publishing in the order that the messages are created, if the broker didn't answer with the control message before the timeout we retry.
So let's assume that you have 2 messages enqueed and one that have expired the timeout. We'll send the first of the 2 published and the one with the timeout expired. If the broker missed the one that we are retransmiting it might be that the message we sent before is received first. Over that we have no control and you should use other mechanisms in you system, like ordered message ID as I suggested or a time stamp in the message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants