updated to use Azure.Messaging.EventHubs 5.2 - latest stable version

This commit is contained in:
spelluru 2020-12-07 21:19:38 -05:00 коммит произвёл Serkant Karaca
Родитель 6fcc98cf4b
Коммит 4e68be93c8
4 изменённых файлов: 48 добавлений и 28 удалений

Просмотреть файл

@ -21,6 +21,14 @@
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -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<EventData>();
// 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)
{

Просмотреть файл

@ -32,20 +32,20 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Azure.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.0.0-preview.9\lib\netstandard2.0\Azure.Core.dll</HintPath>
<Reference Include="Azure.Core, Version=1.5.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.5.0\lib\net461\Azure.Core.dll</HintPath>
</Reference>
<Reference Include="Azure.Messaging.EventHubs, Version=5.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Messaging.EventHubs.5.0.0-preview.4\lib\netstandard2.0\Azure.Messaging.EventHubs.dll</HintPath>
<Reference Include="Azure.Messaging.EventHubs, Version=5.2.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Messaging.EventHubs.5.2.0\lib\netstandard2.0\Azure.Messaging.EventHubs.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Amqp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Amqp.2.4.2\lib\net45\Microsoft.Azure.Amqp.dll</HintPath>
<HintPath>..\packages\Microsoft.Azure.Amqp.2.4.5\lib\net45\Microsoft.Azure.Amqp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.EventHubs, Version=1.0.2.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.EventHubs.1.0.2\lib\net451\Microsoft.Azure.EventHubs.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0-rc1.19456.4\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -56,7 +56,7 @@
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.6.0-rc1.19456.4\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
@ -78,8 +78,8 @@
<Reference Include="System.Reflection.TypeExtensions, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.TypeExtensions.4.5.1\lib\net461\System.Reflection.TypeExtensions.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@ -107,12 +107,21 @@
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.4.6.0\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.4.6.0\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Channels, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.4.6.0-rc1.19456.4\lib\netstandard2.0\System.Threading.Channels.dll</HintPath>
<HintPath>..\packages\System.Threading.Channels.4.6.0\lib\netstandard2.0\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />

Просмотреть файл

@ -1,24 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Azure.Core" version="1.0.0-preview.9" targetFramework="net461" />
<package id="Azure.Messaging.EventHubs" version="5.0.0-preview.4" targetFramework="net461" />
<package id="Microsoft.Azure.Amqp" version="2.4.2" targetFramework="net461" />
<package id="Azure.Core" version="1.5.0" targetFramework="net461" />
<package id="Azure.Messaging.EventHubs" version="5.2.0" targetFramework="net461" />
<package id="Microsoft.Azure.Amqp" version="2.4.5" targetFramework="net461" />
<package id="Microsoft.Azure.EventHubs" version="1.0.2" targetFramework="net461" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0-rc1.19456.4" targetFramework="net461" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="System.Buffers" version="4.5.0" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0-rc1.19456.4" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net461" />
<package id="System.Memory" version="4.5.3" targetFramework="net461" />
<package id="System.Net.WebSockets" version="4.0.0" targetFramework="net461" />
<package id="System.Net.WebSockets.Client" version="4.0.2" targetFramework="net461" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
<package id="System.Reflection.TypeExtensions" version="4.5.1" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net461" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.2.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Encoding" version="4.0.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.0.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.1.0" targetFramework="net461" />
<package id="System.Threading.Channels" version="4.6.0-rc1.19456.4" targetFramework="net461" />
<package id="System.Text.Encodings.Web" version="4.6.0" targetFramework="net461" />
<package id="System.Text.Json" version="4.6.0" targetFramework="net461" />
<package id="System.Threading.Channels" version="4.6.0" targetFramework="net461" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
</packages>