diff --git a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/App.config b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/App.config
index 8291b54e..fb51b296 100644
--- a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/App.config
+++ b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/App.config
@@ -21,6 +21,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/Program.cs b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/Program.cs
index d34a5f81..6945d2ec 100644
--- a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/Program.cs
+++ b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/Program.cs
@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Azure.Messaging.EventHubs;
+using Azure.Messaging.EventHubs.Producer;
namespace WindTurbineDataGenerator
{
@@ -39,31 +40,30 @@ namespace WindTurbineDataGenerator
{
var random = new Random((int)DateTimeOffset.UtcNow.Ticks);
- // create an Event Hubs client using the namespace connection string and the event hub name
- EventHubClient client = new EventHubClient(EventHubConnectionString, EventHubName);
-
- // create a producer object to send messages to the event hub
- EventHubProducer producer = client.CreateProducer();
+ // create an Event Hubs Producer client using the namespace connection string and the event hub name
+ EventHubProducerClient producerClient = new EventHubProducerClient(EventHubConnectionString, EventHubName);
while (!cancellationToken.IsCancellationRequested)
{
try
{
// Simulate sending data from 100 weather sensors
- var devicesData = new List();
-
+ // prepare a batch of events to send to the event hub.
+ EventDataBatch eventBatch = await producerClient.CreateBatchAsync();
for (int i = 0; i < 100; i++)
{
int scaleFactor = random.Next(0, 25);
var windTurbineMeasure = GenerateTurbineMeasure("Turbine_" + i, scaleFactor);
EventData evData = SerializeWindTurbineToEventData(windTurbineMeasure);
- devicesData.Add(evData);
+ // add the event to the batch
+ if (eventBatch.TryAdd(evData) == false)
+ break;
}
Console.Write(".");
- // send the message to the event hub
- await producer.SendAsync(devicesData);
+ // send the batch of events to the event hub
+ await producerClient.SendAsync(eventBatch);
}
catch (Exception ex)
{
@@ -73,7 +73,7 @@ namespace WindTurbineDataGenerator
await Task.Delay(1000, cancellationToken);
}
- }
+ }
private static WindTurbineMeasure GenerateTurbineMeasure(string turbineId, int scaleFactor)
{
diff --git a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/WindTurbineDataGenerator.csproj b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/WindTurbineDataGenerator.csproj
index 9e5da2d2..dac548f6 100644
--- a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/WindTurbineDataGenerator.csproj
+++ b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/WindTurbineDataGenerator.csproj
@@ -32,20 +32,20 @@
4
-
- ..\packages\Azure.Core.1.0.0-preview.9\lib\netstandard2.0\Azure.Core.dll
+
+ ..\packages\Azure.Core.1.5.0\lib\net461\Azure.Core.dll
-
- ..\packages\Azure.Messaging.EventHubs.5.0.0-preview.4\lib\netstandard2.0\Azure.Messaging.EventHubs.dll
+
+ ..\packages\Azure.Messaging.EventHubs.5.2.0\lib\netstandard2.0\Azure.Messaging.EventHubs.dll
- ..\packages\Microsoft.Azure.Amqp.2.4.2\lib\net45\Microsoft.Azure.Amqp.dll
+ ..\packages\Microsoft.Azure.Amqp.2.4.5\lib\net45\Microsoft.Azure.Amqp.dll
..\packages\Microsoft.Azure.EventHubs.1.0.2\lib\net451\Microsoft.Azure.EventHubs.dll
- ..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0-rc1.19456.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
@@ -56,7 +56,7 @@
- ..\packages\System.Diagnostics.DiagnosticSource.4.6.0-rc1.19456.4\lib\net46\System.Diagnostics.DiagnosticSource.dll
+ ..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll
..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll
@@ -78,8 +78,8 @@
..\packages\System.Reflection.TypeExtensions.4.5.1\lib\net461\System.Reflection.TypeExtensions.dll
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
@@ -107,12 +107,21 @@
True
True
+
+ ..\packages\System.Text.Encodings.Web.4.6.0\lib\netstandard2.0\System.Text.Encodings.Web.dll
+
+
+ ..\packages\System.Text.Json.4.6.0\lib\net461\System.Text.Json.dll
+
- ..\packages\System.Threading.Channels.4.6.0-rc1.19456.4\lib\netstandard2.0\System.Threading.Channels.dll
+ ..\packages\System.Threading.Channels.4.6.0\lib\netstandard2.0\System.Threading.Channels.dll
..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
+
+ ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll
+
diff --git a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/packages.config b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/packages.config
index 3a3e6b5c..3283060b 100644
--- a/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/packages.config
+++ b/samples/e2e/EventHubsCaptureEventGridDemo/WindTurbineDataGenerator/packages.config
@@ -1,24 +1,27 @@
-
-
-
+
+
+
-
+
-
+
-
+
-
+
+
+
+
\ No newline at end of file