question

samashtishukla-4035 avatar image
0 Votes"
samashtishukla-4035 asked PramodValavala-MSFT commented

Messages are not been delivered in first attempts,delivery count increases

Hello,

I have service Bus Queues. I have written azure Test function to receives message from Queue by using trigger. I posted 10 messages to queue. I am observing the few messages have deliverycount is 3,4 etc. but I dont see previous attempt for those messages delivery. Not sure How come, if it failed to deliver first time and also should appear in logs. My queue timeout is 1 min. that's quite enough for below empty function.

My requirement is to process one message at a time with FIFO order. How to get that?

Below is code.

  public class Function2
     {
         [FunctionName("ServiceBusTriggerOrderTest")]
         public static void Run([ServiceBusTrigger("in-client-a-queue", Connection = 
         "SBUSConnectionString")] Message message, MessageReceiver messageReceiver,
             Int32 deliveryCount,
              DateTime enqueuedTimeUtc,
             string messageId,
             string Label,
             ILogger log)
         {
               
             try
             {
                 string payload = Encoding.UTF8.GetString(message.Body);
                 log.LogInformation($"C# ServiceBus queue  trigger function processed message: 
                 {payload}");
    
                 //Do your things here, such as Some Actions or Calls Some Service or Another Method
    
                 //complete the message if there is no error
               messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
    
             }
             catch (Exception ex)
             {
                 // Do your error handling here
                 log.LogError($"Error in pressing the message:{ex}");
                 // Send message to DeadLetter Queue 
                 messageReceiver.DeadLetterAsync(message.SystemProperties.LockToken);
    
             }
    
         }
     }

I have tried to make this to public static async Task Run and used await keyword also to complete the task, but same issue.

My host.Json is below:-

 "extensions": {
     "serviceBus": {
       "messageHandlerOptions": {
         "autoComplete": false,
         "maxConcurrentCalls": 1
       }
     }
   }


azure-functionsazure-service-bus
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@samashtishukla-4035 It is possible that you have another client pulling messages, sometimes a local Azure Functions instance that didn't shutdown. It would be best to check for such processes or even try with a new queue to be sure.

Also, are you running the above code as-is with no actions or do you just have them removed here to share?

0 Votes 0 ·

0 Answers