0

This question is related to QueueTrigger and ErrorTrigger in WebJobs. I have one Process Queue method inside one public class(see code below). When any exception comes(e.g Timeout exception) we have 5 retry attempt to process the queue. After 5 unsuccessful attempt we want to send alert mail to one recipient. In Order to do that I have added one method using ErrorTrigger attribute( see code below) and setting threshold and window value. But in my case after 5 retry it does not hit the ErrorTrigger method. Could you please look this code and let me know where I am doing wrong? And if there is other way to send alert mail after 5 unsuccessful retry attempt, please help me.

public static class ProcessQueue
    {
        public static void ProcessQueue([QueueTrigger("testqueue")] string queueMessage, TextWriter logger)
        {
            try
            {
                if (logger != null)
                {
                    //logger.WriteLine(filter.GetDetailedMessage(5));
                    //message.Text = filter.GetDetailedMessage(1);
                }
                throw new TimeoutException(); // Intentionaly throwing timeout exception
              }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void ErrorMonitor(
        [ErrorTrigger("00:00:10", 4)] TraceFilter filter, TextWriter log,
        [SendGrid(To = "abc@gmail.com", Subject = "Error!")]
         SendGridMessage message)
        {
            // log last 5 detailed errors to the Dashboard
            log.WriteLine("Test");
            message.Text = "Failed";
        }
}
Nathan Kuchta
  • 13,482
  • 2
  • 26
  • 35

1 Answers1

1

In your example [ErrorTrigger("00:00:10", 4)] isn't that error trigger: "If there are 4 errors in a 10 second period" (see Error-Monitoring) - which might be bit fast for a queue.

Try [ErrorTrigger("00:05:00", 4)] = four failures in a 5 minute period

Neil Thompson
  • 6,356
  • 2
  • 30
  • 53