Question Problem - Unique Number Generation

naveentej

New member
Joined
Feb 9, 2009
Messages
2
Programming Experience
1-3
Hi All,
I am in the process of developing a messaging framework for a windows application that sends messages to a java application. To be precise when the win app wants to send a message it simply drops the message in a common database table which will be picked up by the java app. The windows application is deployed across 10 application servers (10 instances) over citrix for load balancing.
Each instance of the application is capable of sending a message to the java application and each of these messages should have a unique id. From my end I need to make sure every message generated has to carry a unique id so that they can be identified when necessary. All the messages can be cleared every day or two.
I am not quite sure about a best method of achieving this. Initially I wanted to create a static method that serves the next available id (incrementing the last id by 1). But this approach willn’t guarantee unique number as the application starts only when at least one user is logged on. For e.g .On one server the app starts when a user logs in, he then sends a message and then the application stops when that user logs off. So when a next request for the app comes to that server a new instance will be started. Hope this makes sense and any assistance is appreciated.
 
You can insert a placeholder row into the database, get the ID using SCOPE_IDENTITY() and then update that record when you've created your object.
 
Back
Top