Reputation: 890
I have an Azure WebJob listening to multiple queues...
I can specify the MaxDequeueCount at the job level...
config.UseTimers();
config.Queues.BatchSize = 32;
config.Queues.MaxDequeueCount = 6;
What the best way to set MaxDequeueCounts at the queue level? I know I can get the actual dequeue count and send it to the poison queue "manually" but I was wondering if this can be done in a better way...
Upvotes: 1
Views: 1587
Reputation: 8499
If you want to set different configuration for different queue trigger functions, you could implement your own QueueProcessorFactory and reset some configurations of context based on the queue name.
public class MyQueueProcessorFactory : IQueueProcessorFactory
{
public QueueProcessor Create(QueueProcessorFactoryContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if (context.Queue.Name == "queue1")
{
context.MaxDequeueCount = 2;
}
else if (context.Queue.Name == "queue2")
{
context.MaxDequeueCount = 4;
}
return new QueueProcessor(context);
}
}
To use the custom QueueProcessorFactory, we need to set the QueueProcessorFactory property as following.
JobHostConfiguration config = new JobHostConfiguration();
config.Queues.QueueProcessorFactory = new MyQueueProcessorFactory();
JobHost host = new JobHost(config);
Upvotes: 6