Skip to content

Commit

Permalink
Merge pull request #5 from FrankieTF/DevUpdateSdk
Browse files Browse the repository at this point in the history
Updated to Azure.messaging.EventHubs
  • Loading branch information
jongio authored Oct 19, 2020
2 parents db761f7 + a49be38 commit 38a4da0
Show file tree
Hide file tree
Showing 10 changed files with 329 additions and 150 deletions.
57 changes: 0 additions & 57 deletions EventHubSampleData/EventHub2/Program.cs

This file was deleted.

80 changes: 0 additions & 80 deletions EventHubSampleData/EventHub2/SendSampleData.csproj

This file was deleted.

7 changes: 0 additions & 7 deletions EventHubSampleData/EventHub2/packages.config

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2003
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendSampleData", "EventHub2\SendSampleData.csproj", "{39C6D8A8-E6E7-4140-9DF3-B1F904884C4B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendSampleData", "EventHubSampleSendData\SendSampleData.csproj", "{39C6D8A8-E6E7-4140-9DF3-B1F904884C4B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -20,6 +20,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2437AC5E-AA35-4674-B183-7399EF3941AC}
SolutionGuid = {5EDE07DF-1DBC-4E89-B4B0-D95F6F4EB2D7}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<system.serviceModel>
<extensions>
Expand Down Expand Up @@ -43,6 +43,46 @@
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<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.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.1.0" newVersion="1.5.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Channels" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
61 changes: 61 additions & 0 deletions EventHubSampleData/EventHubSampleSendData/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Azure.Messaging.EventHubs;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using Azure.Messaging.EventHubs.Producer;

namespace SendSampleData
{
class Program
{
const string eventHubName = "test-hub";
const string connectionString = @"<YourConnectionString>";

public static async Task Main(string[] args)
{
await EventHubIngestionAsync();
}

public static async Task EventHubIngestionAsync()
{
await using (var producerClient = new EventHubProducerClient(connectionString, eventHubName))
{
int counter = 0;
for (int i = 0; i < 100; i++)
{
int recordsPerMessage = 3;
try
{
var records = Enumerable
.Range(0, recordsPerMessage)
.Select(recordNumber => $"{{\"timeStamp\": \"{DateTime.UtcNow.AddSeconds(100 * counter)}\", \"name\": \"{$"name {counter}"}\", \"metric\": {counter + recordNumber}, \"source\": \"EventHubMessage\"}}");

string recordString = string.Join(Environment.NewLine, records);

EventData eventData = new EventData(Encoding.UTF8.GetBytes(recordString));
Console.WriteLine($"sending message {counter}");
// Optional "dynamic routing" properties for the database, table, and mapping you created.
eventData.Properties.Add("Table", "TestTable");
eventData.Properties.Add("IngestionMappingReference", "TestMapping");
eventData.Properties.Add("Format", "json");

using EventDataBatch eventBatch = await producerClient.CreateBatchAsync();
eventBatch.TryAdd(eventData);

await producerClient.SendAsync(eventBatch);
}
catch (Exception exception)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("{0} > Exception: {1}", DateTime.Now, exception.Message);
Console.ResetColor();
}

counter += recordsPerMessage;
}
}
}
}
}
Loading

0 comments on commit 38a4da0

Please sign in to comment.