I have the following logic in a WebJob using the new 0.3.0-beta WebJobs SDK. When my code fails processing the message, the Azure dashboard shows an Aggregate Exception (which makes sense since this is async). HOWEVER, it does not retry processing the message.
The very little documentation I've been able to find indicates that the message should be retried within 10 minutes of failure. Is this not the case with the new SDK?
public static Task ProcessMyMessageAsync(
[QueueTrigger(Config.MY_QUEUE)] string msg,
int dequeueCount,
CancellationToken cancellationToken)
{
var processor = Config.Container.GetInstance<IMessageProcessor>();
return processor.HandleJobAsync(msg, dequeueCount, cancellationToken);
}
The exception I get stems from a SQL Timeout exception (its a db query against SQL Azure in my code):
System.AggregateException: System.AggregateException: One or more errors occurred.
---> System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details.
---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception: The wait operation timed out
You should set MaxDequeueCount.
JobHostConfiguration jobHostConf = new JobHostConfiguration();
jobHostConf.Queues.MaxDequeueCount = 10;
var host = new JobHost(jobHostConf);
host.RunAndBlock();
That will retry 10 times, before the messages is put on a dead/bad letter queue.
You could also use a custom retry policy in the function. I suggest you look at "The Transient Fault Handling Application Block" https://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx
Or you could enable retry in EF with a SqlAzureExecutionStrategy https://msdn.microsoft.com/en-us/data/dn456835.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With