Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unique id throughout application lifetime

Tags:

java

I am developing a jboss Java EE application where I need to send messages through a messaging system (JMS or AMQP optional). Approx. there will be around 10k to 15k messages per second. The requirement is to generate a unique id for each outgoing message that is not used any time in the past, even after application restart i.e. the id should not repeat again through the application lifetime (from day 1 of application use until decommissioned)

I will prefer solutions based on

  1. Numeric value only (what data type?)
  2. String

The auto-generation of the id should be atomic.

like image 528
GBP Avatar asked Dec 04 '25 07:12

GBP


1 Answers

Java provides a method for generating Universally Unique Identifiers in the UUID class

Wikipedia has an explanation why the probability that these generate a message with the same ID is negligible.

like image 172
Uku Loskit Avatar answered Dec 06 '25 21:12

Uku Loskit