Home > front end >  Error while using ServiceBusProcessor - Azure.Messaging.ServiceBus SDK
Error while using ServiceBusProcessor - Azure.Messaging.ServiceBus SDK

Time:12-15

I am getting an exception after the StartProcessingAsync() method. The debug pointer goes to the "ProcessorErrorAsync" method. I followed similar steps provided in the link - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample04_Processor.md Am I missing some steps here? Exception Details: 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;
        }

CodePudding user response:

Thank you jsquire and arunprakashn. Posting your suggestion as an answer to help other community members.

Turns out there was an issue with referencing new Amqp nuget. I see that the latest Azure.Amqp is a dependency that comes along the new service bus SDK, but still was having reference issues. I deleted the Amqp nuget several times and re-added but that didn't solve the issue. the ".nuspec" file was still having reference to the legacy SDK and when I commented it, re-added the new Azure.Messaging.Servicebus nuget, the error vanished.

  • Commented the line for the legacy SDK as shown below:
<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>

You can refer to GitHub issue: Error while using ServiceBusProcessor - Azure.Messaging.ServiceBus SDK

  • Related