1 Reply Latest reply on Feb 3, 2005 4:40 AM by Gregory none

    distributed design question and jboss

    adog fourteen Newbie

      Hi,
      I am new to jboss and j2ee and have a design question to pose to you all and how you would solve it.

      Here is a simple example. Lets say I have an ordering system, every time an order is placed a special order number we manage must be incremented sequentially. No two threads can manipulate the order number (increment it) at the same time. This order number is very particular to the type of thing being ordered and it is not a simple number but an alphanumeric string.

      On top of this we have several load-balanaced application servers all that have the code to increment this order number. So basically my question boils down to distributed synchronization of the execution of this method. How do you prevent simultanious access to a block of code in a distributed load balanced environment?

      How would you do this in J2ee design? Stateless session beans? what about in a clustered environment with jboss? Can you have single threaded access to code in EJB's or a j2ee setup?

        • 1. Re: distributed design question and jboss
          Gregory none Newbie

          Hi

          Just starting with J2EE myself, but will take a shot none the less,
          since it looks like an interesting question.

          I think you can look into JNDI Directory services,
          which allows you to store attributes on objects, and supposed
          to be persistent across all of the clusters.

          So, I would try to create a separate JNDI name/object pair
          for each possible order type, and store the last used id number
          as an attribute on this object. This way you should be able to
          have those order numbers unique.

          BTW, that's just an idea, haven't tried it myself.