2016-11-18 42 views

回答

3

可以在功能通過eventHub配置塊host.json描述here做到這一點。例如: -

{ 
    "eventHub": { 
     "maxBatchSize": 500, 
     "prefetchCount": 100 
    } 
} 

當我們創建我們應用這些配置設置EventProcessorOptionsEventProcessorHost(見here)。

1

斯蒂芬,

MaxBatchSize可以通過EventProcessorOptions進行配置,你可以創建一個新的EventHubConfiguration時,把它作爲一個參數。

var options = EventProcessorOptions.DefaultOptions; 
options.MaxBatchSize = 50; 
var eventHubConfig = new EventHubConfiguration(options); 
string eventHubName = "MyHubName"; 
eventHubConfig.AddSender(eventHubName, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=SendRule;SharedAccessKey=xxxxxxxx"); 
eventHubConfig.AddReceiver(eventHubName, "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=yyyyyyy"); 

config.UseEventHub(eventHubConfig); 
JobHost host = new JobHost(config); 

正如你可以在EventHubConfiguration.cs源代碼,如果沒有指定EventProcessorOptions公告,MaxBatchSize設置爲1000,而不是10默認。

public EventHubConfiguration(
     EventProcessorOptions options, 
     PartitionManagerOptions partitionOptions = null) 
{ 
    if (options == null) 
    { 
     options = EventProcessorOptions.DefaultOptions; 
     options.MaxBatchSize = 1000; 
    } 
    _partitionOptions = partitionOptions; 

    _options = options; 
} 
相關問題