pberggreen
pberggreen

Reputation: 958

Peeking Azure ServiceBus messages does not return scheduled messages

I am trying to use ScheduledEnqueueTimeUtc to schedule messages for future processing, but Peek only returns Active and Deferred messages.

This is the code I use to Peek messages:

    public static async Task<IEnumerable<BrokeredMessage>> GetMessagesAsync(string connectionString, string queueName, int take)
    {
        var queue = QueueClient.CreateFromConnectionString(connectionString, queueName);
        return await queue.PeekBatchAsync(take).ConfigureAwait(false);
    }

Scheduled messages with ScheduledEnqueueTimeUtc set to sometime in the future are NOT returned.

After the scheduled time, I get the message with State = Scheduled, but this is not what I expected.

From the name "ScheduledEnqueueTimeUtc" it makes sense that the message isn't visible because it isn't enqueued yet. However it bothers me if I can have an infinite number of scheduled messages hanging out there without being able to see them.

Did I make a mistake or is there another way to get future scheduled messages?

Upvotes: 2

Views: 901

Answers (1)

pberggreen
pberggreen

Reputation: 958

I found the problem: I was sending the scheduled message to a Topic - not a Queue.

Obviously, this means that the message isn't visible in the subscription queue before the scheduled time.

Using regular queues, Peek works as expected and returns both Active, Deferred and Scheduled messages, as one would expect :-)

Upvotes: 3

Related Questions