Reputation: 9386
I'm trying to work out how I can further messages from a service bus topic.
I can get the first ~250 messages from a Dead Letter Queue, but when I try to get the next 250, I get the first 250 again.
The Subscription to the Topic I'm targeting has over 60'000 messages in the Dead Letter Queue.
I'm using the Azure.Messaging.ServiceBus
NuGet package with version 7.0.1
await using var client = new ServiceBusClient(ConnectionString);
var serviceBusReceiver = client.CreateReceiver(TopicName, SubscriptionName, new ServiceBusReceiverOptions
{
SubQueue = SubQueue.DeadLetter
});
for (var i = 0; i < 1000; i += 250)
{
var serviceBusReceivedMessages = await serviceBusReceiver.PeekMessagesAsync(250, i);
foreach (var message in serviceBusReceivedMessages)
{
Console.WriteLine(message.MessageId);
}
}
Can anyone help?
Upvotes: 1
Views: 1000
Reputation: 26057
Peaking messages with NServiceBus doesn't work that way. When peaking N messages, you'll get up-to N, not exactly N. Therefore, what I would suggest is to increase your fromSequenceNumber
parameter passed into ServiceBusReceiver.PeekMessagesAsync
by the value of serviceBusReceivedMessages.Count
.
Upvotes: 1