Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 714839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:07:11+00:00 2026-05-14T05:07:11+00:00

I’m re-implementing a old BBS MUD game in Java with permission from the original

  • 0

I’m re-implementing a old BBS MUD game in Java with permission from the original developers. Currently I’m using Java EE 6 with EJB Session facades for the game logic and JPA for the persistence. A big reason I picked session beans is JTA.

I’m more experienced with web apps in which if you get an OptimisticLockException you just catch it and tell the user their data is stale and they need to re-apply/re-submit. Responding with “try again” all the time in a multi-user game would make for a horrible experience. Given that I’d expect several people to be targeting a single monster during a fight I think the chance of an OptimisticLockException would be high.

My view code, the part presenting a telnet CLI, is the EJB client. Should I be catching the PersistenceExceptions and TransactionRolledbackLocalExceptions and just retrying? How do you decide when to stop?

Should I switch to pessimistic locking?

Is persisting after every user command overkill? Should I be loading the entire world in RAM and dumping the state every couple of minutes?

Do I make my session facade a EJB 3.1 singleton which would function as a choke point and therefore eliminating the need to do any type of JPA locking? EJB 3.1 singletons function as a multiple reader/single writer design (you annotate the methods as readers and writers).

Basically, what is the best design and java persistence API for highly concurrent data changes in an application where it is not acceptable to present resubmit/retry prompts to the user?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:07:12+00:00Added an answer on May 14, 2026 at 5:07 am

    I can’t help but feel that you’re massively overcomplicating what should be a simple issue.

    Commercial and successful MMOs often take an approach like this:

    Every few minutes or after a significant action:
        copy the player data
        pass the player data to a background thread
    
    In the background thread:
        write each piece of player data to the database
    

    There aren’t ‘highly concurrent’ data changes because each player saves his own data, to different rows of the database. (In some cases, this is literally one row – several commercial games just store the player data as a Blob against the user id.) Sometimes the data is a bit stale, but that’s unimportant. It’ll only be a problem if the server crashes because otherwise you’ll eventually get the current state into the DB. This isn’t inter-bank credit transfers we’re talking about.

    As for MUDs and BBS games, their algorithm would have been simpler still:

    Every few minutes or after a significant action:
        For each property in the player object:
            write a property to the player's file
    

    Again, there is no contention here, because each player has their own file.

    Persisting after every user command is indeed overkill, unless your game is highly monetized and there’s a risk of people suing you if they lose their +3 Axe of Awesome due to a server crash.

    And what else in the world do you need to persist other than the players? There are often negative gameplay implications for persisting everything else, so usually you don’t want to do this.

    As for ‘concurrent’ access to the same monster, as per your example, it doesn’t matter. If you have a single process, the monster should be in RAM. Your single process arbitrates who gets to hit the monster and in what order. This isn’t a job for your persistence layer. Handle the game logic in the game and persist the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try to close you solution, delete YourSolution.suo file in solution's… May 14, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer (b) Should suffice. The array's deallocator will release all contained… May 14, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer Actually @Azeem.Butt is way wrong, at least partially. A non-Reducisaurus… May 14, 2026 at 8:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.