3
votes

I'm using NServiceBus 3.3.8 with MSMQ under Windows 7. Currently the sending and receiving is working fine for both recoverable and express messages. However, I noticed that the MSMQ storage area is not cleaned up after the messages are consumed by the reader. This is causing me to cleanup the MSMQ storage manually when it reaches the maximum allowed queue size.

I tried decreasing the MessageCleanupInterval in registry and restarting MSMQ service, but still I don't see the messages are removed. When examined the pxxxxxx.mq files in storage folder, those contained both recoverable and express messages that I sent.

Has anybody got a clue on the reason for this message accumulating? And is there a way to prevent it with some configurations in MSMQ/NServiceBus?

1
Is this at all related to - stackoverflow.com/questions/1561063/… ??Leptonator
No, this is not related to access rights. Just on increasing of the size of MSMQ storage area.Nalin

1 Answers

2
votes

Empty storage files are deleted after 6 hours. This is for performance reasons - it is quicker for MSMQ to re-use an existing file then to create a new one.

If you open a P*.MQ file, you will indeed see data from previous messages. This is exactly the same as if you analysed any random sector of a hard disk. If a message has been processed, the storage area is flagged as free (in the corresponding L*.MQ file) so it can be overwritten by a future message. There is no gain from clearing storage space after each message has been read.

Storage files will hang around if they contain just a single message. There is no defragmentation to compact usage of storage files. If a file does not get purged after the clean-up interval or a restart then it is not empty. Check the MSMQ performance counters to see if the system as a whole (rather then just the queue you're interested in) has any messages lying around.

"However, I noticed that the MSMQ storage area is not cleaned up after the messages are consumed by the reader. This is causing me to clean-up the MSMQ storage manually when it reaches the maximum allowed queue size."

This is incorrect. If you delete storage files and the quota is then no longer reached, you must have deleted real messages to free up space. Empty storage files have zero impact on your message quota.