'SubscriptionClient' does not contain a definition for 'PeekBatch' and ReceiveBatch

668 views Asked by At

I have a netstandard2.1 application and I am using nuget package "Microsoft.Azure.ServiceBus" Version="4.1.1".

I am creating a azure service bus SubscriptionClient and trying to use PeekBatch and ReceiveBatch, but I am getting below erros, What is missing here?

'SubscriptionClient' does not contain a definition for 'PeekBatch' and no accessible extension method 'PeekBatch' accepting a first argument of type 'SubscriptionClient' could be found

'SubscriptionClient' does not contain a definition for 'ReceiveBatch' and no accessible extension method 'PeekBatch' accepting a first argument of type 'SubscriptionClient' could be found

 _subscriptionClient = new SubscriptionClient(connectionString, topicName, subscriptionName, ReceiveMode.ReceiveAndDelete);
            
            _subscriptionClient.PrefetchCount = 16;

            while (_subscriptionClient.PeekBatch(16).Any())
            {
                var pendingMessages = _subscriptionClient.ReceiveBatch(16, TimeSpan.FromSeconds(1))?.ToList();
                if (pendingMessages != null)
                {
                    foreach (var message in pendingMessages)
                    {
                        // do processing of the message
                    }
                }
            }
1

There are 1 answers

0
Athanasios Kataras On BEST ANSWER

You can't use the batch methods and prefetching at the moment from .net standard or core.

Check the documentation here: https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-performance-improvements?tabs=net-standard-sdk#prefetching-and-receivebatch

Prefetching

This section only applies to the WindowsAzure.ServiceBus SDK, as the Microsoft.Azure.ServiceBus SDK does not expose batch functions.

Note that WindowsAzure here: https://www.nuget.org/packages/WindowsAzure.ServiceBus/

Please note that this package requires at least .Net Framework 4.6.2.

Is .net only and does not support net core or net standard