Reputation: 21
The requirement : it is require to generate a unique, number for a each and every web request, this number is used to identify the transaction uniquely and track the transaction propagation and this number will return to client for future reference. this is a java web application i would like to know the methods available to do this..(without connenct db get a key value)Thanks in advance
Upvotes: 1
Views: 1105
Reputation: 340903
If you are running only single instance of your application, simply use AtomicLong.incrementAndGet(). However it needs to be persisted prior to shutdown, otherwise it will always start from 0
after restart.
Otherwise UUID class has to be used which is universally unique 128-bit value.
Upvotes: 2
Reputation: 6088
Have you tried with the java UUID?
Here is a tutorial on how to generate them
Upvotes: 1