Out of order execution

Applications are quite commonly integrated in asynchronous fashion with each other. The messages needing guaranteed delivery need to supported by retry mechanism in sender application. Such retries lead to situations where two requests get processed out of order. Also, they can get processed simultaneously causing concurrency which in synchronous world would never happen. How?

To illustrate out of order execution scenario, lets assume the sender application has a retry interval of 10 minutes and...

00:00 App1 sends Req1 to App2

(Req1 cannot complete as the network is down)

00:03 App1 sends Req2 to App2

(Req2 successfully processed)

00:10 App1 re-sends Req1 to App2

When an application purely updates the data it has with the data supplied by in the request by the caller is something I would characterize as pure data update. To deal with out of order execution in such cases I propose following solution.

  1. As part of API contract we expect the caller to provide the time at which the request was initiated.
  2. The receiver application maintains the time at which the corresponding data is updated in its database against every record.
  3. The receiver application updates its data if this time in the request is newer is the time it has in its database for that record. If this is not true then it simply ignores the request, may be returning a warning to the caller.