Skip to content

Commit 236016b

Browse files
authored
Switch default LoadBalancingStrategy to Greedy (Azure#19460)
1 parent 2f1912a commit 236016b

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Release History
22

3-
## 5.0.0-beta.3 (Unreleased)
3+
## 5.0.0-beta.3 (2021-03-11)
44

5+
### Changes
6+
7+
- Default balancing strategy changed to greedy.
58

69
## 5.0.0-beta.2 (2021-03-09)
710

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Config/EventHubOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Azure.Messaging.EventHubs;
66
using Azure.Messaging.EventHubs.Consumer;
77
using Azure.Messaging.EventHubs.Primitives;
8+
using Azure.Messaging.EventHubs.Processor;
89
using Microsoft.Azure.WebJobs.EventHubs.Processor;
910
using Microsoft.Azure.WebJobs.Hosting;
1011
using Newtonsoft.Json;
@@ -21,6 +22,7 @@ public EventHubOptions()
2122
{
2223
TrackLastEnqueuedEventProperties = false,
2324
MaximumWaitTime = TimeSpan.FromMinutes(1),
25+
LoadBalancingStrategy = LoadBalancingStrategy.Greedy,
2426
PrefetchCount = 300,
2527
DefaultStartingPosition = EventPosition.Earliest,
2628
};

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/tests/EventHubsClientFactoryTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Azure.Messaging.EventHubs;
99
using Azure.Messaging.EventHubs.Consumer;
1010
using Azure.Messaging.EventHubs.Primitives;
11+
using Azure.Messaging.EventHubs.Processor;
1112
using Azure.Messaging.EventHubs.Producer;
1213
using Azure.Storage.Blobs;
1314
using Microsoft.Azure.WebJobs.EventHubs.Processor;
@@ -228,6 +229,22 @@ public void RespectsConnectionOptionsForProcessor(string expectedPathName, strin
228229
Assert.AreEqual(expectedPathName, processor.EventHubName);
229230
}
230231

232+
[Test]
233+
public void DefaultStrategyIsGreedy()
234+
{
235+
EventHubOptions options = new EventHubOptions();
236+
237+
var configuration = CreateConfiguration(new KeyValuePair<string, string>("connection", ConnectionString));
238+
var factory = new EventHubClientFactory(configuration, Mock.Of<AzureComponentFactory>(), Options.Create(options), new DefaultNameResolver(configuration));
239+
240+
var processor = factory.GetEventProcessorHost("connection", "connection", "consumer");
241+
EventProcessorOptions processorOptions = (EventProcessorOptions)typeof(EventProcessor<EventProcessorHostPartition>)
242+
.GetProperty("Options", BindingFlags.NonPublic | BindingFlags.Instance)
243+
.GetValue(processor);
244+
245+
Assert.AreEqual(LoadBalancingStrategy.Greedy, processorOptions.LoadBalancingStrategy);
246+
}
247+
231248
private IConfiguration CreateConfiguration(params KeyValuePair<string, string>[] data)
232249
{
233250
return new ConfigurationBuilder().AddInMemoryCollection(data).Build();

0 commit comments

Comments
 (0)