How do I cancel processing or process a specified number of queue messages for an Azure Service Bus Queue using the DotNet SDK without the Delivery Count going up? Increasing the Delivery count causes things to go into a dead letter message
Following these directions using QueueClient instead of SubscriptionClient I was able to write two console apps, a sender and a receiver of Service Bus Queues. If I want to process things in the queue in batch (eg. Every minute I want to process 100 Queue Items or every Minute request 100 Queue items) how would I gracefully cancel the processing that's happening after calling RegisterMessageHandler(event, cancellationToken)?
//throws System.OperationCanceledException exception so the DeliveryCount goes up
await queueClient.CloseAsync();
//throws Microsoft.Azure.ServiceBus.MessageNotFoundException exception so DeliveryCount also goes up
await queueClient.CancelScheduledMessageAsync(message.SystemProperties.SequenceNumber);
I tried following the prefetch best practices but that seems to only act as a "buffer" of how many it requests not a total batch.