Blocking Event Queue Functions

So I’m trying to implement a way of Queuing data to be sent over MQTT (Or some other FIFO buffer). But if there is no MQTT connection currently can I block the event loop until the connection returns? and if one fails is there a way to push suspend that function and try again so that the data is always sent in the order it was added. I’m not sure if the event loop can be used for this is? or should I just make a circular buffer

Also on a side note is there a way I could save this queue to a config tree?


EDIT: I just thought about it, is it efficient to just run another thread for posting then wait in that thread until the connection returns and the post is successful to stop the other events (data posts) from being popped off?

Instead I put all of the messages into a singly linked list (used a timer to call the publish function rather than event loop) and Queue them on the end and if they fail they get stacked on the front so they stay in order unless they fail more than 10 times.

Still unsure what to do if the Queue fills or the App closes might try config tree figure out a way to save it into a file?