I'd like to guarantee a transaction runs once, and once only.  Let's
say I'm simulating a bank transfer of $5 from AccountA to AccountB.

The normal transaction is not idempotent:

Repeat until success {
 * start txn
 * debit $5 from AccountA
 * credit $5 to AccountB
 * commit txn
}

If this inadvertently runs multiple times, I will have very unhappy
customers.  Maybe I should do this:

Create TxnID entity instance
Repeat until success {
 * start txn
 * load TxnID (if null, return success immediately)
 * debit $5 from AccountA
 * credit $5 to AccountB
 * delete TxnID
 * commit txn
}

With the pain of adding a third entity to my XG transaction (and a
cron that prunes really old, abandoned TxnIDs) it seems that I this
does the trick.  Or am I missing something?  Is this the best way to
accomplish once-only transactions?  Is there an alternative approach?

Thanks in advance,
Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to