【发布时间】:2022-01-17 18:26:01
【问题描述】:
在 StartProcessingAsync() 方法之后出现异常。调试指针指向“ProcessorErrorAsync”方法。我遵循了链接中提供的类似步骤 - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample04_Processor.md 我在这里错过了一些步骤吗? 异常详情:error.Exception.Message:
Method not found: 'System.Threading.Tasks.Task`1<System.Collections.Generic.IEnumerable`1<Microsoft.Azure.Amqp.AmqpMessage>> Microsoft.Azure.Amqp.ReceivingAmqpLink.ReceiveMessagesAsync(Int32, System.TimeSpan, System.TimeSpan, System.Threading.CancellationToken)'.
private void ListenerBind(string key, ServiceBusProcessorOptions onMessageOptions)
{
ServiceBusClient tempClient = this._cacheClient.Get(key);
ServiceBusProcessor tempProcessor = tempClient.CreateProcessor(this._topicName, this._subscriptionName, onMessageOptions);
try
{
//temp.OnMessageAsync(this.MessageProcessCallBackAsync, onMessageOptions);
tempProcessor.ProcessMessageAsync += MessageProcessCallBackAsync;
tempProcessor.ProcessErrorAsync += ProcessErrorAsync;
tempProcessor.StartProcessingAsync();
}
catch (InvalidOperationException ex)
{
this._logger.Log($"{ex.Message}", EventLevel.Informational);
}
catch (Exception ex)
{
this._logger.LogException(ex);
}
}
private Task ProcessErrorAsync(ProcessErrorEventArgs error)
{
Exception ex = new Exception(
$" , Action {error.ErrorSource}, " +
$" , Endpoint {error.FullyQualifiedNamespace}" +
$",EntityPath {error.EntityPath} "
, error.Exception);
this._logger.LogException(ex);
this._onErrorCallback(ex, string.Empty);
return Task.CompletedTask;
}
【问题讨论】:
-
很高兴您的问题已得到解决。您可以接受并投票赞成答案,以便对可能面临相同问题的其他社区成员有所帮助。
标签: azure azureservicebus azure-sdk-.net