Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...it was ingeniously designed and all those clicks were for my own good... and that was even before I got my speedy and useful answer to my tekkie question that I eventually posted..."

Geography

Where in the world do Tek-Tips members come from?

How implement the Singeltone design pattern in a clustered environment

royc75 (Programmer)
17 Aug 06 0:51
Hello,

I need to manage a certain BigDecimal class member in a web application which will not be destroyed. This class member represents a key in a database which from few reasons I would like to manage on my own and I don't use EJBs.
In order to implement that, I have created a private static class member at the application and a get method in order for the other views to get it's value.
The get method checks if the value is null.
In case it is it queries the Database for the maximum value and return it + 1 to the requestor.
In case it is not null it simply increments the current value by 1 and returns it to the requestor.
According to my assumption, a DB query should happen only once since this member is static, yet when I monitor the application I see it queries the Database occasionally, which mean that the member has been destroyed.
After an investigating this I noticed thatthe application is running in a clustered envirinment with 3 servers which means that 3 classes are loaded (one per JVM), every class maintains own MAX_ID  and therefore I get into collisions.
Suppose it is not possible to migrate the whole application to use EJBs, is there a solution for this case? Perhaps a certain J2EE Design Pattern to manage the key in a clustered environment which can expose the key generation method to my application?
royc75 (Programmer)
19 Aug 06 3:16

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close