-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated service bus with new microsoft.azure.servicebus dotnet library #1
Changes from 13 commits
30248d8
2c2da32
553f70e
3d7599a
742f101
aba238b
953d01d
6b9d889
e0c5c0d
3c452d0
adc8e6a
6e2725c
adf4aa6
3d89644
799bd97
374487a
d26f0e4
b5d31e1
2d37b3a
003238f
4321d14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be replaced entirely with <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> |
||
<dependentAssembly> | ||
<assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" /> | ||
</dependentAssembly> | ||
<dependentAssembly> | ||
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\build\common.props" /> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IsPackable>False</IsPackable> | ||
|
||
<OutputType>Exe</OutputType> | ||
<StartupObject>Foundatio.ReceiverConsole.Program</StartupObject> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="appsettings.json" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Foundatio.TestHarness" Version="5.1.1474" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should pull in Foundatio 6.0. We just need to add the following nuget config (https://github.com/FoundatioFx/Foundatio.Redis/blob/feature/logging/NuGet.config minus the loresoft on line 5) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the sample projects. Now I am referencing Foundatio 5.1.1562 which is the latest and the greatest. I dont see 6.0 in the Updates at all. Am I missing something |
||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Foundatio.AzureServiceBus\Foundatio.AzureServiceBus.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Foundatio.Messaging; | ||
using Foundatio.Queues; | ||
using System.Threading.Tasks; | ||
|
||
namespace Foundatio.ReceiverConsole { | ||
class Program { | ||
static void Main(string[] args) { | ||
|
||
|
||
try { | ||
var o = new Receiver(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "o"? 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can now do static There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good tip Blake. I just realized i have removed the reference of sample project from the solution but didnt delete the sample files from the repo. Will be deleting all the samples. I think our unit test cases are great enough to test all the possible scenarios |
||
o.Run(args).GetAwaiter().GetResult(); | ||
} | ||
catch (Exception e) { | ||
Console.WriteLine(e); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commented out lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be able to drop all assembly info's as well or at least just provide a title and description as we do in the Foundatio Project (logging branch) |
||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
//[assembly: AssemblyTitle("Foundatio.ReceiverConsole")] | ||
//[assembly: AssemblyDescription("")] | ||
//[assembly: AssemblyConfiguration("")] | ||
//[assembly: AssemblyCompany("")] | ||
//[assembly: AssemblyProduct("Foundatio.ReceiverConsole")] | ||
//[assembly: AssemblyCopyright("Copyright © 2017")] | ||
//[assembly: AssemblyTrademark("")] | ||
//[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("2257e266-9561-4215-9b8c-b229a251d1a3")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
//[assembly: AssemblyVersion("1.0.0.0")] | ||
//[assembly: AssemblyFileVersion("1.0.0.0")] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using System.Text; | ||
using System.Threading; | ||
using Foundatio.Messaging; | ||
using Foundatio.Queues; | ||
using System.Threading.Tasks; | ||
using Foundatio.Tests.Utility; | ||
namespace Foundatio.ReceiverConsole { | ||
class Receiver { | ||
private async Task TestTopic() { | ||
IMessageBus messageBus = | ||
new AzureServiceBusMessageBus(new AzureServiceBusMessageBusOptions() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we update to the latest foundatio 6, it brings in the logging changes and we've migrated everything to the new cross plat configuration system). We can accept the pr as is but if you wanted to tackle that it's pretty fun to play with and learn :) |
||
Topic = "Topic1", | ||
ClientId = Configuration.GetSection("ClientId").Value, | ||
TenantId = Configuration.GetSection("TenantId").Value, | ||
ClientSecret = Configuration.GetSection("ClientSecret").Value, | ||
SubscriptionName = "Subscriber1", | ||
ConnectionString = Configuration.GetSection("ConnectionString").Value, | ||
SubscriptionId = Configuration.GetSection("SubscriptionId").Value, | ||
ResourceGroupName = Configuration.GetSection("ResourceGroupName").Value, | ||
NameSpaceName = Configuration.GetSection("NameSpaceName").Value, | ||
ReceiveMode = Microsoft.Azure.ServiceBus.ReceiveMode.ReceiveAndDelete | ||
}); | ||
await messageBus.SubscribeAsync<string>(msg => { Console.WriteLine(msg); }); | ||
Console.ReadKey(); | ||
} | ||
|
||
private Task GotQueueEntry(IQueueEntry<object> queueEntry, CancellationToken cancellationToken) { | ||
var msg = queueEntry.Value; | ||
Console.WriteLine($"Recieved the message: Body: {msg} "); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private async Task TestAutoDeQueue() { | ||
IQueue<object> queue = new AzureServiceBusQueue<object>(new AzureServiceBusQueueOptions<object>() { | ||
Name = "queue1", | ||
ClientId = Configuration.GetSection("ClientId").Value, | ||
TenantId = Configuration.GetSection("TenantId").Value, | ||
ClientSecret = Configuration.GetSection("ClientSecret").Value, | ||
ConnectionString = Configuration.GetSection("ConnectionString").Value, | ||
SubscriptionId = Configuration.GetSection("SubscriptionId").Value, | ||
ResourceGroupName = Configuration.GetSection("ResourceGroupName").Value, | ||
NameSpaceName = Configuration.GetSection("NameSpaceName").Value, | ||
WorkItemTimeout = TimeSpan.FromMinutes(3) | ||
}); | ||
|
||
|
||
try { | ||
await queue.StartWorkingAsync(GotQueueEntry, true); | ||
} | ||
catch (Exception e) { | ||
Console.WriteLine(e); | ||
} | ||
Console.ReadKey(); | ||
queue.Dispose(); | ||
} | ||
|
||
private async Task TestDeQueue() { | ||
string message; | ||
IQueue<object> queue = new AzureServiceBusQueue<object>(new AzureServiceBusQueueOptions<object>() { | ||
Name = "queue1", | ||
ClientId = Configuration.GetSection("ClientId").Value, | ||
TenantId = Configuration.GetSection("TenantId").Value, | ||
ClientSecret = Configuration.GetSection("ClientSecret").Value, | ||
ConnectionString = Configuration.GetSection("ConnectionString").Value, | ||
SubscriptionId = Configuration.GetSection("SubscriptionId").Value, | ||
ResourceGroupName = Configuration.GetSection("ResourceGroupName").Value, | ||
NameSpaceName = Configuration.GetSection("NameSpaceName").Value, | ||
WorkItemTimeout = TimeSpan.FromMinutes(3) | ||
}); | ||
|
||
do { | ||
Console.WriteLine("Waiting to receive messages. Press enter to recv more messages or Ctrl-Z to quit"); | ||
message = Console.ReadLine(); | ||
if (message == null) | ||
return; | ||
try { | ||
|
||
var stats = await queue.GetQueueStatsAsync(); | ||
Console.WriteLine($"Stats:Dequeued {stats.Dequeued} Enqueued {stats.Enqueued}"); | ||
var result = await queue.DequeueAsync(TimeSpan.FromSeconds(5)); | ||
|
||
if (result != null) { | ||
|
||
await queue.CompleteAsync(result); | ||
Console.WriteLine($"Recieved the message: Body: {result.Value} "); | ||
} | ||
stats = await queue.GetQueueStatsAsync(); | ||
Console.WriteLine($"Stats:Dequeued {stats.Dequeued} Enqueued {stats.Enqueued}"); | ||
} | ||
catch (Exception e) { | ||
Console.WriteLine(e); | ||
} | ||
} while (message != null); | ||
|
||
Console.ReadKey(); | ||
} | ||
|
||
public async Task Run(string[] args) { | ||
//await TestTopic(); | ||
await TestDeQueue(); | ||
//await TestAutoDeQueue(); | ||
|
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"TenantId": "", | ||
"ClientId": "", | ||
"ClientSecret": "", | ||
"SubscriptionId": "", | ||
"DataCenterLocation": "Central US", | ||
"ServiceBusSku": "Standard", | ||
"ResourceGroupName": "", | ||
"NameSpaceName": "", | ||
"ConnectionString": "" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be entirely replaced by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we switch to the new project system I don't think we can remove most of these references. We can do this in a second pr as well. |
||
<package id="Exceptionless.RandomData" version="1.1.35" targetFramework="net46" /> | ||
<package id="Foundatio" version="5.1.1474" targetFramework="net46" /> | ||
<package id="Foundatio.Logging.Xunit" version="5.1.1474" targetFramework="net46" /> | ||
<package id="Foundatio.TestHarness" version="5.1.1474" targetFramework="net46" /> | ||
<package id="Microsoft.Azure.Amqp" version="2.1.1" targetFramework="net46" /> | ||
<package id="Microsoft.Azure.Management.ServiceBus" version="1.0.0" targetFramework="net46" /> | ||
<package id="Microsoft.Azure.ServiceBus" version="1.0.0" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Configuration" version="1.1.2" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Configuration.Abstractions" version="1.1.2" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="1.1.2" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="1.1.2" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Configuration.Json" version="1.1.2" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="1.1.1" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.FileProviders.Physical" version="1.1.1" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.FileSystemGlobbing" version="1.1.1" targetFramework="net46" /> | ||
<package id="Microsoft.Extensions.Primitives" version="1.1.1" targetFramework="net46" /> | ||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.16.0" targetFramework="net46" /> | ||
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net46" /> | ||
<package id="Microsoft.Rest.ClientRuntime" version="2.3.9" targetFramework="net46" /> | ||
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.9" targetFramework="net46" /> | ||
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="NETStandard.Library" version="1.6.1" targetFramework="net46" /> | ||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" /> | ||
<package id="Nito.AsyncEx.Coordination" version="1.0.2" targetFramework="net46" /> | ||
<package id="Nito.AsyncEx.Tasks" version="1.0.1" targetFramework="net46" /> | ||
<package id="Nito.Collections.Deque" version="1.0.0" targetFramework="net46" /> | ||
<package id="Nito.Disposables" version="1.0.0" targetFramework="net46" /> | ||
<package id="System.AppContext" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Collections" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net46" /> | ||
<package id="System.Console" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Globalization" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.IO" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Linq" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Net.Http" version="4.3.2" targetFramework="net46" /> | ||
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Reflection" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Runtime.Serialization.Xml" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Threading" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net46" /> | ||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net46" /> | ||
<package id="xunit" version="2.2.0" targetFramework="net46" /> | ||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net46" /> | ||
<package id="xunit.assert" version="2.2.0" targetFramework="net46" /> | ||
<package id="xunit.core" version="2.2.0" targetFramework="net46" /> | ||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net46" /> | ||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net46" /> | ||
</packages> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't need this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove the app.config completely in all projects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have actually deleted the sample project itself. I didn't find any value to that when we have good amount of unit test cases covering all the test cases.