sequence number generate for web application
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
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.
Have you tried with the java UUID?
Here is a tutorial on how to generate them
精彩评论