I've built something on Google App Engine that acts as a backend for an iPhone app. In the app, there are interactions that are pushed out to social networks via their APIs. So the typical workflow is like this:
- User uses the iPhone app to do "something"
- App Engine app is alerted via HTTP
- App Engine alerts social network that user did "something." If the user were to check their profile on that network, their activity via the app would be displayed. So, as far as the user is concerned, what they did probably worked.
- App Engine needs to do some persistence on its own, but when it tries, a DatastoreTimeException is thrown. And now the data is in a funky state.
So what's a good way to handle this? By nature of the problem I'd love to wrap it in a "transaction", but there's no way to roll back what got sent to the Social Network. So, I'm thinking more along the lines of how do you handle a DatastoreTimeException? Should I just wrap it in a try block and give it another go? Is it a better idea to show the user an error, and then when they try again, "skip" the social network interaction so that it isn't pushed out twice? Is there another idea that I'm not thinking of here?