We have an application which on every resource update(resource update, create, delete)creates a message and puts it on a queue. This message is picked up by a worker process, converted to a format that the receiving application (lets call it a hub) understands and sends it. The hub implements a policy of last writer wins (implemented using mongodb). Whenever the sending application fails to send a message, we enqueue it to a failed queue, which is picked up by a job and sent again in few mins. The problem here is how can we ensure consistency when we send the messages again as it might overwrite a more recent write (due to the last writer policy).
One thought was to use timestamps but there as well there is a possibility when there are multiple consumers processing the message off the queue, there as well it might result in an inconsistent state due to order and speed of processes being different.
I have been reading of multiple implementations of Lamport clock and vector clock. Can anyone suggest a better solution to handle consistency in a last writer wins policy, especially in .net.