Your device should set a LWT. This will be issued when there is no update within a certain period by the broker. This will inform subscribers that a device go offline
For a message queue you have to implement something yourself that take care of this during the mqtt node disconnected to your broker.
A function node pushing the data into an array on it’s own context as log it gets don’t get “connected” form a status node supervising the mqtt out could do the job (if setting up a sql sever as in the contrib note mentioned below is a little bit overkill). If it receives “connected” it could empty the array to the mqtt out node and pass all incoming messages.
Perhaps more reading here