public byte [ ] get ( ) { // Uniqueness is guaranteed by combining the hostname and the current nano second, hashing the result, and // selecting the first x bytes of the result String timestamp = String . valueOf ( System . nanoTime ( ) ) ; byte [ ] digestString = ( hostname + timestamp ) . getBytes ( ) ; return Arrays . copyOf ( messageDigest . digest ( digestString ) , messageIdLength ) ; }
Creates a message id that should be unique on every call . The message ID needs to be unique for every message . If a message is chunked then each chunk in a message needs the same message ID .