Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

John Breakwell

share|improve this answer
Hmm, I thought so. Thank you – Nishkar Apr 20 '11 at 16:40

This is probably too late for Nishkar's issue, but might be useful to someone else.

As John said, you can't change message properties once it's sent. So if you need something like this only solution is to use one more intermediary queue where you would read messages, modify whatever you want and send them to original destination queue. Since this is simple processing it should work quickly and not hit your 30-min time to be received. One thing to note is that final message will not be identical to original one. Apart from these properties you change, MSMQ will also set new message ID, sent time, etc.

It's an extra step but could be a solution if you don't have any other way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.