I have a design template that I struggled with how best to prevent duplication of data publishing.
Here are the steps:
- The client sends data using a unique guid (generated by the client guid - guaranteed unique)
- Server-side software ensures that the client pointer does not yet exist in the database
- starts a transaction
- process data (may take 1 to 20 seconds depending on the payload)
- commits a transaction
Here are the scenarios: A client sends data using guid "1", and then retransmits data using "1" before step (5) gets to the initial data transfer, then the transaction is processed twice.
What is the best design pattern to prevent this without using semaphores or blocking? The user should be able to resend the message if for some reason the first message did not work (server hardware problem, etc.).
Thank!
source
share