Resubmitting a document in a flow service

Hi
As part of publish-subscribe model, the documents are published to the broker and all the documents are getting logged into the database.
If any error occurs on the subscriber-side, we want to log the errors to a sepcific table for the corresponding document id. There will be another service to resubmit these error documents programmetically. There are built-in services available for getting the document for the given doucment id.
But how will I get the document id for a particular pubished document.Publishable document envelope has UUID. But this UUID is different from documentId in logging database.
Please suggest in this regard.

Thanks in advance
Regards
Raghavendra