I have one azure service bus topic subscription where messages keeps pump up.
Below code is basically receive one message at a time and processing it and relevant result stored into database.
I tried to set MaxConcurrentCalls to 10
, but it's exhausted my database connection pool due to the database work design.
So I thought to get 10 messages from subscription at a time (receive in a batch of N number of messages) and want to process with one database call.
I don't see any batch api options, is this possible?
I am using Microsoft.Azure.ServiceBus
nuget version 4.1.1
.
_subscriptionClient = new SubscriptionClient(connectionString, topicName, subscriptionName);
// Register the callback method that will be invoked a message of interest is received
_subscriptionClient.RegisterMessageHandler(
async (message, token) =>
{
if (await ProcessMessage(message, token))
{
await _subscriptionClient.CompleteAsync(message.SystemProperties.LockToken);
}
},
new MessageHandlerOptions(ExceptionReceivedHandler) { MaxConcurrentCalls = 1, AutoComplete = false });