admin管理员组文章数量:1129424
I have a .NET Windows Service project deployed to an Azure App Service. My goal is to receive 100,000 messages from an Azure Service Bus queue and process these messages in a message handler. However, after processing approximately 800 messages, the service stops receiving new messages and becomes idle. How can I ensure that the Azure Service Bus continues to receive and process all 100,000 messages without stopping?
public void ReceiveMessages(string queueName, string namespaceConnectionString, string appInsightInstrumentationKey, string domainUrl, SecretClient client)
{
var clientOptions = new ServiceBusClientOptions()
{
TransportType = ServiceBusTransportType.AmqpWebSockets,
};
var serviceBusClient = new ServiceBusClient(namespaceConnectionString, clientOptions);
var adminClient = new ServiceBusAdministrationClient(namespaceConnectionString);
var processorOptions = new ServiceBusProcessorOptions
{
AutoCompleteMessages = false,
MaxAutoLockRenewalDuration = TimeSpan.FromHours(1)
};
var serviceBusProcessor = serviceBusClient.CreateProcessor(queueName, new ServiceBusProcessorOptions());
_serviceBusProcessor = serviceBusProcessor;
var handlerParams = new MessageHandlerParameter
{
AppInsightInstrumentationKey = appInsightInstrumentationKey,
DomainUrl = domainUrl,
Client = client
};
try
{
// Add handler to process messages;
serviceBusProcessor.ProcessMessageAsync += (args) => MessageHandlerAsync(args, handlerParams);
// Add handler to process any errors;
serviceBusProcessor.ProcessErrorAsync += ErrorHandlerAsync;
serviceBusProcessor.StartProcessingAsync();
Console.WriteLine("Wait sometime for processing to start");
Task.Delay(Timeout.InfiniteTimeSpan);
}
catch (Exception ex)
{
}
finally
{
_ = serviceBusProcessor.DisposeAsync();
_ = serviceBusClient.DisposeAsync();
}
}
I am expecting to receive 100k messages without stopping.
本文标签:
版权声明:本文标题:c# - Azure service bus queue not received all messages from the queue When the project is deployed on app service - Stack Overfl 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736744677a1950706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论