问题描述
我一直在使用Azure存储队列通过QueueTrigger
属性来提供WebJob.我将QueueTrigger
配置为使多个项目出队以进行并行处理,如下所示:
I have been using Azure Storage Queues to feed a WebJob, using the QueueTrigger
attribute. I configure my QueueTrigger
to dequeue a number of items for concurrent processing, like this:
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.NameResolver = new QueueNameResolver();
config.Queues.NewBatchThreshold = 10;
JobHost host = new JobHost(config);
host.RunAndBlock();
}
public static void ExecuteStorageQueueItem([QueueTrigger("%AzureQueueName%")] CloudQueueMessage message, TextWriter logger)
{
ProcessRequest(message.AsString, logger);
}
我希望使用服务总线. ServiceBusConfiguration
上的MaxConcurrentCalls
参数是否允许相同的自动并行执行?例如:
I would prefer to use Service Bus. Does the MaxConcurrentCalls
parameter on ServiceBusConfiguration
allow for the same automatic parallel execution? For example:
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.NameResolver = new QueueNameResolver();
ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
serviceBusConfig.MessageOptions.MaxConcurrentCalls = 10;
config.UseServiceBus(serviceBusConfig);
JobHost host = new JobHost(config);
host.RunAndBlock();
}
public static void ExecuteServiceBusItem([ServiceBusTrigger("%ServiceBusQueueName%")] BrokeredMessage message, TextWriter logger)
{
ProcessRequest(message.GetBody<string>(), logger);
}
我不确定MaxConcurrentCalls
是否按照我的想法做!
I'm not sure whether MaxConcurrentCalls
does what I think it does!
推荐答案
从本质上讲,MaxConcurrentCalls
定义了客户端用于处理队列的线程数量.
Essentially yes, MaxConcurrentCalls
defines the amount of threads used by the Client to process the queue.
当调用QueueClient.OnMessage
方法时,它将启动不断轮询的无限循环上的消息泵. OnMessageOptions.MaxConcurrentCall
设置对消息泵应启动的回调.
更多背景故事:为Windows Azure服务总线引入事件驱动的消息编程模型
这篇关于使用ServiceBusTrigger时的Azure WebJob并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!