I will reprogram the old BBS MUD game in Java with permission from the original developers. I am currently using Java EE 6 with EJB Session facades for game logic and JPA for saving. The big reason I chose the beans session is because of the JTA.
I am more experienced with web applications in which if you get an OptimisticLockException, you just catch it and tell the user that their data is out of date and they need to resubmit / resend. Responding to "try again" all the time in a multiplayer game would create a terrible experience. Given that I expect several people to be targeted at the same monster during the battle, I think the probability of an OptimisticLockException exception will be high.
My view code, part representing the telnet CLI, is an EJB client. Should I catch the values โโof PersistenceExceptions and TransactionRolledbackLocalExceptions and just try again? How do you decide when to stop?
Should I switch to pessimistic blocking?
Is it saved after the overflow of each user command? Should I load the whole world into RAM and unload the state every couple of minutes?
Am I making my session facade an EJB 3.1 singlet that will function as a decay point and therefore eliminate the need to make any JPA locks? EJB 3.1 singletones function as a design with multiple readers / single writers (you comment on methods as readers and writers).
Basically, what is the best Java-compatible design and API for highly competitive data changes in an application where it is not acceptable to submit a re-send / retry request to a user?
source
share