0

I am trying to schedule messages in azure service bus and few messages are getting stuck in scheduled queue and never returned to active queue even after reaching ScheduledEnqueueTimeUtc

The code for sending scheduled BrokeredMessage is very normal:

var message = new BrokeredMessage(info);
message.Properties.Add("Action", "Bookmark");
message.ContentType = "Info";
message.ScheduledEnqueueTimeUtc = DateTime.UtcNow.AddMinutes(Int32.Parse(ConfigurationManager.AppSettings["Delay"]));
var serviceBusClient = QueueClient.CreateFromConnectionString(ConfigurationManager.AppSettings["ConnectionString"], ConfigurationManager.AppSettings["ServiceBusQueueName"]);
serviceBusClient.Send(message);

Out of 20,000 messages I sent while testing only 6 messages were stuck and also at random times.

Below is the screenshot in debug mode Screenshot for invalid ExpiresAtUtc

Notes: Initially I thought messages were stuck because of bad ExpiresAtUtc but after some reading found that when a new messages is scheduled its ExpiresAtUtc is 12/31/9999 11:59:59 PM Also I found that when a messages is scheduled by cloning a message from Queue then ExpiresAtUtc for the scheduled message will not be 12/31/9999 11:59:59 PM but will be its proper ExpiresAtUtc time even when it is in scheduled queue

  • That's not a problem. `ExpiresAtUtc` is assigned to year 9999 by default – Mikhail Shilkov Sep 14 '17 at 07:39
  • Firstly, as Mikhail said, the ``ExpiresAtUtc`` of a scheduled BrokeredMessage is assigned to year 9999 by default. Secondly, in [this article](https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.brokeredmessage.scheduledenqueuetimeutc?view=azureservicebus-4.1.1) we can find: ``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.``do those 6 scheduled messages not still get enqueued until today? – Fei Han Sep 14 '17 at 08:34
  • Yes @FredHan even today they are stuck, if you see the EnqueuedTimeUtc, its 9/11, so its stuck in scheduled queue for last 3days and there is no workload on that queue – user844105 Sep 14 '17 at 09:55
  • Messages would not normally just get stuck. Either they were deferred or there's something wrong with the queue. Can you pick this messages and verify they are not deferred? – Sean Feldman Sep 14 '17 at 13:02
  • Hi @SeanFeldman they are not deferred messages, as you see in the screenshot, the state is "Scheduled" Out of 20,000 messages that i processed that day in same manner, only 6 messages failed – user844105 Sep 14 '17 at 13:06

1 Answers1

0

As we mentioned, the ExpiresAtUtcof a scheduled message is assigned to year 9999 by default, which should not be the cause of the issue.

According to your screenshot, those messages do not become active (state of message is “Scheduled”), you can try to call CancelScheduledMessageAsync() method and check if the message can be canceled.

client.CancelScheduledMessageAsync(sequenceNumber)

Besides, you can try to create a new Azure Service Bus queue and run your code to send scheduled messages to that new queue, and check if same issue can appears in the new queue. If the issue only appears in that specific queue, you can create a support request and get help from Azure support engineer.

Fei Han
  • 26,415
  • 1
  • 30
  • 41
  • Hi @FredHan I tried as per your suggestion and found that we are using older version of API 2.1.4 and CancelScheduledMessageAsync is not working in that version. I tried creating a new queue and kept a daemon to keep on sending messages, none of them failed (sent nearly 1million messages. – user844105 Sep 18 '17 at 09:39
  • It seems that there's something wrong with that specific queue, as I did, you can create a use a new queue for your program. Or you can try to get help from Azure support engineer via creating a support request. – Fei Han Sep 19 '17 at 01:45
  • Sure I will raise a support request. – user844105 Sep 19 '17 at 06:15
  • I can create a new queue and go ahead but it is very important for me to know whats wrong with the current queue because if the same happens in production, its a huge loss. – user844105 Sep 19 '17 at 08:55
  • ``if the same happens in production, its a huge loss`` I agree with you. Do you create a support request? If Azure support engineer help you find the problem with that specific queue, you can share with us. – Fei Han Sep 20 '17 at 09:08
  • Sure @FredHan i will – user844105 Sep 22 '17 at 06:38