0

In my Azure queue triggered webjobs I either don't set BatchSize at all (defaults to 16) or I set it:

JobHostConfiguration.Queues.BatchSize = ...;

Anecdotally (hitting F5 frequently) it seems like no matter what the setting is the number of items in the queue always decreases by 1. I'd like to see what's actually happening - how can I see the number of messages that were grabbed at any given moment. This value doesn't appear to be part of the queue trigger metadata.

Howiecamp
  • 2,981
  • 6
  • 38
  • 59

1 Answers1

0

As far as I know, the BatchSize is the maximum number of queue messages that are picked up simultaneously to be executed in parallel (default is 16).

In my opinion, it means azure webjobs will execute 16 thread at one time to execute the function.

If you want to see the number of messages that were grabbed at any given moment.

I suggest you could write a test demo on the local develop environment.

I suggest you could try below functions.

 public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
        {
            Console.WriteLine("start to execute queue : " + message );
            //log.WriteLine(message);
            Thread.Sleep(10000);
            Console.WriteLine("End to execute queue : " + message);
        }

The "Thread.Sleep(10000)" in the code will sleep the thread 10 seconds.

Then you could add 20 message in the queue firstly and run the webjobs.

You will find the result is like below:

It will firstly execute 16 thread to execute the function: enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
  • That's a good idea. If I see the message is only being grabbed one at a time, how would you suggest I troubleshoot that? – Howiecamp Apr 24 '17 at 17:21
  • As far as I know, if you set breakpoint in your webjob, it will stop all the thread to waite you countinue running the code. So no matter how frequently hitting F5, it will just run one thread to get one queue message.Besides,if you publish your webjobs to azure, you could set its 'AzureWebJobsDashboard' connectionString, if you set this connection string, azure webjobs will automatic log the details information about how the webjobs run. You could use the "log.WriteLine " to log the information as my post shows. By reading these logs, you could troubleshoot the error. – Brando Zhang Apr 25 '17 at 09:29