How to generate a MessageID correctly


i wrote an Openfire-Plugin, that can send Messages in multi user chats.

Unfortunately the recieving clients need a unique ID for every message but the messages of the Plugin do not have an ID.

Is there a way to generate an ID so there are no duplications?

Or ist there a way that the Openfire will generate the ID’s for me?

Best regards

I’d use java.util.UUID.randomUUID().toString()