I'm building a game www.mobwarrior.com
and am having a wee problem with transactions and I'm not sure about the best way to do it.
I've got a session filter on the servlets which starts a transaction and comits it at the end of a user action which works fine.
I also have a back ground process that every 10 minutes grabs all the users, calculates their scores and ranks them. Sometimes this process is not able to commit the transaction.
I'm guessing this is because the user has logged in and done something as it was updating all the users rank.
I'm not sure how else to do this with out starting and commiting a heap of transcations. The other way I was thinking is starting transaction, calc user score, commit, repeat for all users.
Then start transaction, rank all users, commit.
Is this the best way to do it? Are starting that many transactions expensive?
Any ideas would be great, Thanks