Not knowing exactly what your MQTT messages are, yes, a FIFO with D values could be used to lookup a message to publish (you could also create a FIFO of strings to put the messages directly into the queue). I don't think you need a loop instruction, just call a Task whenever your queue is not empty.
FIFOUNLOAD to D0
IF D0 = 1 STRPRINT SS0 "Message 1"
IF D0 = 2 STRPRINT SS0 "Message 2", etc. (You can also use STRPRINT's Lookup function to do it all in one rung)
MQTTPUB with a Payload of SS0.
Depending on your MQTT broker, you may need a timer of a few seconds to prevent exceeding your allocated rate.