Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Service Bus Queue ScheduledEnqueueTimeUtc Delayed

I am encountering an odd problem. I have a cloud service A that puts messages into a service bus queue for another cloud service B to read. Cloud service B can take about a second to process what it needs to do, then it puts a message back into a queue for cloud service A. When cloud service B does this it uses the ScheduledEnqueueTimeUtc to put a delay of around 1 - 10 seconds on the message.

Last Friday the azure outage brought this application down completely. When I brought it back online, ScheduledEnqueueTimeUtc is always causing a delay of at least 10 seconds. For instance, I generate a datetime that is between 1 and 10 seconds in the future. I set that as the ScheduledEnqueueTimeUtc and I also put that time as a property on the message I am sending, I compare that datetime property to the EnqueuedTimeUtc property of the message when I receive it back in cloud service A. These 2 times should be pretty close together, and that is the way it has been working for months up until last Friday.

So now cloud service B is saying it put this message into the queue in 1 second. Cloud Service A says it didn't get into the queue for 12-14 seconds. I am using async methods when putting messages into queues. There is no delay if I do not use ScheduledEnqueueTimeUtc, the times match up close enough when I look at them back in cloud service A. But if I set ScheduledEnqueueTimeUtc even 1 second in the future it seems to not show up in the queue for 12-14 seconds.

I am working around this now by using quartz.net to schedule messages instead of setting the ScheduledEnqueueTimeUtc property. But it just seems really odd that this started happening.

like image 625
Brad Johnson Avatar asked Mar 01 '13 16:03

Brad Johnson


People also ask

What is ScheduledEnqueueTimeUtc?

ScheduledEnqueueTimeUtc is a time when message is going to be available (within hundreds of miliseconds) on the queue but not necessary delivered, this depends on load and state of the queue.

What happens when the Service Bus queue max delivery count in Azure?

Maximum delivery count The default value is 10. Whenever a message has been delivered under a peek-lock, but has been either explicitly abandoned or the lock has expired, the delivery count on the message is incremented. When the delivery count exceeds the limit, the message is moved to the DLQ.

Is Azure Service Bus asynchronous?

Azure Service Bus support both Asynchronous messaging patterns and Synchronous messaging patterns. Applications typically use asynchronous messaging patterns to enable several communication scenarios.

How do I clear my Azure Service Bus queue?

Delete all messages in a Azure Service Bus queue at once - using "Purge" from context menu.


1 Answers

From ScheduledEnqueueTimeUtc Property's documentation:

"Message enquing time does not mean that the message will be sent at the same time. It will get enqueued, but the actual sending time depends on the queue's workload and its state."

That property causes the message not to be delivered immediatelly. It won't be delivered before the set time, but there is not assurance that it will be delivered exactly at that time.

If you need high resolution scheduling, Quartz may be an option. You might also evaluate the new job scheduler that is part of the Mobile Services preview.

like image 113
Fernando Correia Avatar answered Sep 29 '22 09:09

Fernando Correia