Question

I have an interesting issues and wanted some input from someone with a similar experience. I have an Android app that makes a REST call (e.g. accepts an open order). App sends out the request and runs into connectivity issues, meanwhile server gets the request, changes order state and sends back a response (e.g. HTTP 200). But, the app, missing its network connection, does not receive the response and gets an timeout exception. If I try to accept the order again, I get response that it is already taken (in this case by me).

The question would be - what should be the best approach to such situation. For now, the requirements are to run a loop if I get a timeout exception (in some scenarios it's a loop including another web call to check whether this order did not appear in my "CurrentOrders"). I don't like this design and was wondering what would be better. Maybe the web call could return 200 (success) if the same client tries to accept the same order twice or more? Or how would some of you handle such situation?

Was it helpful?

Solution

I'm not quite clear about the semantic of your "accept" action.

What does it actually do? On the one hand it seems it updates the order state. It should be then idempotent since further updates should not change anything.

On the other hand you have some kind of external state (order is taken). This can't be done through REST, you have to use some kind of unique id to resolve the conflict. Look at this question for more info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top