title: MQ WebSphere MessageID Woes
body: <p>Another newb MQ Server question. I am building an ASP.NET C# application that needs to browse the message, save the message text to a database, and then read the message so it's removed from the queue. That way if the saving fails, the message is still in the queue and I don't have to ask it to be resent.</p>
  
  <p>The problem is I need a way to uniquely identify the message when it is browsed so I can read (remove) it after a successful database save. I read about Correlation IDand MessageId and have trouble getting values. </p>
  
  <p>The CorrelationId is always blank, so I can't use that. The messageId I cannot figure out how to convert it to something readable.</p>
  
  <p>For example:
  MQ Explorer shows a messageID of: <em>AMQ AZMEUNK62   bS Ý.</em> MQ Explorer says the message ID bytes are: <em>414D512055534E4A5241523632202020126210532001DD02</em>. </p>
  
  <p>How do I convert the message ID bytes to that human readable string and back? </p>
  
  <p>I've tried the code below which returns unusable result (<em>AMQ AZMEUNK62   ↕b►S ☺?☻)</em></p>
  
  <pre><code>string msgIdStr = System.Text.Encoding.Default.GetString(mqMessage.MessageId); 
  string strMsgId = Encoding.UTF8.GetString(mqMessage.MessageId, 0, mqMessage.MessageId.Length);
  </code></pre>
  
  <p>I tried these methods because of these posts- </p>
  
  <p><a href="https://stackoverflow.com/questions/15754550/passing-ids-in-ibm-mq-client">Passing ids in IBM MQ client</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1003275/converting-byte-to-string-in-c-sharp">How to convert byte[] to string?</a></p>
  
  <p>Any thoughts most welcome.</p>