0

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.

Nishkar
  • 3
  • 2

2 Answers2

1

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

John Breakwell
  • 757
  • 5
  • 11
0

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.