title: Correlate MSMQ End-to-End trace with WCF Trace and application level logging
body: <h1>Background:</h1>
  
  <p>I'm troubleshooting a problem where messages sent by WCF over transactional MSMQ (with netMsmqBinding) seem to disappear. The code that uses WCF is in a third-party assembly which I cannot change. I have few clues to what the problem is, but plan to enable various tracing capabilities in order to pin-point where the problem relies.</p>
  
  <h1>Context:</h1>
  
  <ol>
  <li><p>I have enabled MSMQ <a href="http://technet.microsoft.com/en-us/library/cc730882.aspx" rel="noreferrer">End-to-End Tracing</a>. It logs two events for every message that gets sent.</p>
  
  <ul>
  <li>One event when a message is written to the outgoing queue. This message contain the MSMQ message id (which is composed by a guid and an integer, ie 7B476ADF-DEFD-49F2-AF5A-0CF27C5152C0\6481271).</li>
  <li>Another event when that message is sent across the network.</li>
  </ul></li>
  <li><p>I have enabled verbose <a href="http://msdn.microsoft.com/en-us/library/ms733025.aspx" rel="noreferrer">WCF Tracing</a>.</p></li>
  <li><p>I also have application level logging that logs a message IDs defined by the application code (let's call this the "application message id").</p></li>
  <li><p>I have enabled positive and negative source journaling on the MSMQ messages that get sent.</p></li>
  <li><p>I have enabled journaling on the receiving queue.</p></li>
  </ol>
  
  <h1>Problem:</h1>
  
  <p>When messages go missing, I know the missing message's application id (it's logged by the sending side). I would now like to look at the End-to-End trace to see 
  whether the message was written to the outgoing queue or not.</p>
  
  <p><strong>How can I correlate the events in the End-to-End trace with the application level logs and WCF traces?</strong></p>
  
  <h1>Ideas:</h1>
  
  <ul>
  <li><p>When sending a MSMQ message using the managed MSMQ API in System.Messaging, the message's MSMQ id is available after the message is sent. However, I have not found a way to log this when WCF is performing the send operation. The WCF trace logs a MSMQMessageId guid, but this value is, surprisingly, not the actual MSMQ id as I guessed it would be. <strong>Is it possible to access the actual MSMQ message id and log it?</strong></p></li>
  <li><p>Log the native thread id in the application log along with the application level id and a time stamp. The native thread id is logged to the End-to-End trace by MSMQ, so this might actually be sufficient to correlate. This is plan B for me if I don't find a more elegant solution.</p></li>
  </ul>