I\'m using the mq library of IBM to read messages from MQ queues. Now I need to retrieve the messageid of the message. I now it is in the message header under the name messa
I have successfully implemented the cycle of getting the MQ MessageId and converting it to a hexadecimal string for local storage and then converting it back to a byte[] when using it to query MQ again later, using the Apache Commons Codec thus:
import org.apache.commons.codec.binary.Hex;
String mqMessageId = Hex.encodeHexString(message.messageId);
message.messageId = Hex.decodeHex(mqMessageId.toCharArray());
I like this approach because it depends on a well maintained library from a well known and respected organization, and I do not have to maintain any additional methods.
None the less I would like to acknowledge Roger's comments above because they put me on the trail that lead to Apache Commons Codec.