【问题标题】:Error while using ServiceBusProcessor - Azure.Messaging.ServiceBus SDK使用 ServiceBusProcessor 时出错 - Azure.Messaging.ServiceBus SDK
【发布时间】: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


【解决方案1】:

谢谢jsquirearunprakashn。发布您的建议作为帮助其他社区成员的答案。

原来在引用新的 Amqp nuget 时存在问题。我看到最新的 Azure.Amqp 是新服务总线 SDK 附带的依赖项,但仍然存在参考问题。我多次删除了 Amqp nuget 并重新添加,但这并没有解决问题。 “.nuspec”文件仍然引用旧版 SDK,当我评论它时,重新添加了新的 Azure.Messaging.Servicebus nuget,错误消失了。

  • 对旧版 SDK 的行进行了注释,如下所示:
<group targetFramework=".NETFramework4.8">
        <dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0"/>
        <dependency id="Microsoft.Rest.ClientRuntime" version="2.2.0"/>
        <dependency id="Newtonsoft.Json" version="12.0.3"/>
        <dependency id="Ninject" version="3.3.4"/>
        <!--<dependency id="WindowsAzure.ServiceBus" version="5.1.0"/>-->
        <dependency id="Polly" version="7.1.0"/>
        <dependency id="RabbitMQ.Client" version="5.0.1"/>
        <dependency id="System.Diagnostics.DiagnosticSource" version="4.5.0"/>
        <dependency id="System.Diagnostics.TraceSource" version="4.3.0"/>
        <dependency id="System.Diagnostics.Tracing" version="4.3.0"/>
      </group>

可以参考GitHub issue:Error while using ServiceBusProcessor - Azure.Messaging.ServiceBus SDK

【讨论】:

    猜你喜欢
    • 2021-12-23
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 2021-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多