0
votes

I'm working with Azure Service Bus Queues in a request/response pattern using two queues and in general it is working well. I'm using pretty simple code from some good examples I've found. My queues are between web and worker roles, using MVC4, Visual Studio 2012 and .NET 4.5.

During some stress testing, I end up overloading my system and some responses are not delivered before the client gives up (which I will fix, not the point of this question).

When this happens, I end up with many messages left in my response queue, all well beyond their ExpiresAtUtc time. My message TimeToLive is set for 5 minutes.

When I look at the properties for a message still in the queue, it is clearly set to expire in the past, with a TimeToLive of 5 minutes.

I create the queues if they don't exist with the following code:

namespaceManager.CreateQueue(
                    new QueueDescription( RequestQueueName )
                    {
                        RequiresSession = true,
                        DefaultMessageTimeToLive = TimeSpan.FromMinutes( 5 ) // messages expire if not handled within 5 minutes
                    } );

What would cause a message to remain in a queue long after it is set to expire?

1

1 Answers

1
votes

As I understand it, there is no background process cleaning these up, only the act of moving the queue cursor forward with a call to Receive will cause the server to skip past and dispose of messages which are expired and actually return the first message that is not expired or none if all are expired.