MSMQ – How to set the message expiration externally

msmq

How can I make MSMQ automatically expire messages if they have been waiting in a queue for longer than a period of time, say, 30 minutes?

We don't have control of the system that creates these messages in order to set the MaxTimeToReceive property of the messages.

Best Answer

You can't.

Timeouts are always set when the application creates the message. The value is either provided by the code or taken from the sender's queue manager's defaults. Once set and sent, that's it.

If you have no control of the system sending the messages then you're out of luck and will have to provide a manual method of cleaning up old messages.

Cheers
John Breakwell