Writing in MSMQ’s personal journal


If you are doing some testing and want to enable journal messages so you can track what’s going on, make sure you know what sort of journaling you’ve picked because there are two types:



 


Positive Source Journaling


If you set the MESSAGE to Journal (via application code) then this tells the Sending queue manager to put a copy in the “Journal messages” queue under “System Queues” in Computer Management on the sending machine. This copy is only created when the message successfully leaves the machine. 



 


Negative Source Journaling


If you set the MESSAGE to Dead Letter (via application code) then this tells the Sending queue manager to put a copy in the “Dead-letter messages” or “Transactional dead-letter messages” queue under “System Queues” in Computer Management on the sending machine. This copy is only created when the message fails to leave the machine (or fail to be read in the case of transactional messages).  


 


 


Target Journaling 


If you set the QUEUE to Journal (via ticking the “Enabled” box) then this tells the Receiving queue manager to put a copy in the “Journal messages” queue under the destination queue in Computer Management on the receiving machine. This copy is only created when the message is successfully read from the queue.


 


 


Important Notes



  • The sending machine is not always the machine you think it is. If you are making use of Routing Servers then each machine is a sender to the next one in the chain. Messages can therefore fail to send at any point so check the System Queues on all of the servers.

  • MSMQ will not clean up journal messages for you. Unless you have some process in place, be it automated or manual, to purge the queues or process these messages then your machine will eventually implode.To prevent this happening:


    • Use Performance Monitor to check how many Journal messages there are in the system.


      • On the sender: “MSMQ QueueMessages in Journal QueueComputer Queues”

      • On the receiver: “MSMQ QueueMessages in Journal Queue<serverqueuename>”

    • If you enable the Journal property of a queue, make sure you also choose “Limit journal storage to (KB):”

    • If you enable the Journal property of a message, make sure you also choose  “Limit journal storage to (KB):” in Storage limits for the sending machine. 

 


Comments (7)

  1. Hans says:

    As always: NIce to read those tips as reminders of what too easily may be forgotten. Thanks for your valuable blog, John!

  2. Justin says:

    Is there any way to look at the journal via .NET to see when the last read message was arrived/sent?

  3. MSDNArchive says:

    Hi Justin,

    You can open up a journal queue just like any other. This page on MSDN has examples for referencing journal queues:

    MessageQueue Class

    http://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.aspx

    You would then need to PEEK the messages to read their arrived/sent properties.

    Cheers

    John Breakwell (MSFT)

  4. Justin says:

    Thanks, was able to get it working, the major challenge i had in the end was the correct notation.

    to access a private queue journal was .private$queuejournal$

    almost every website i checked dropped the $ on the private when referring to journal. i found it was required in both places.

  5. MSDNArchive says:

    Hi Justin,

    Yes, dropping the $ from Private is such a basic error and I hope you didn’t find any Microsoft sites doing this.

    With practice it will become second nature to include it  🙂

    Cheers

    John

  6. Klaus says:

    Well, I tend to disagree. If I use Justin’s syntax then I get error C00E0006 "An invalid parameter was passed to a function." when I try to open a journal queue.

    But I succeed if instead I specify the name as ".private$queue;journal"

    I use direct format names, and I’m on Windows 2000.

  7. MSDNArchive says:

    Hi Klaus,

    Both are valid.

    ".private$queuejournal$" works for system.messaging (which my link above references).

    ".private$queue;journal" works for COM (http://msdn.microsoft.com/en-us/library/ms883473.aspx).

    Cheers

    John Breakwell (MSFT)