Skip to content

Commit eb439bc

Browse files
authored
Merge pull request #11 from NCodeGroup/azure
Adding AzureServiceBus transport
2 parents b9b0d86 + b3a6e5d commit eb439bc

18 files changed

+1313
-28
lines changed
Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
</PropertyGroup>
77

8-
<ItemGroup>
9-
<None Remove="appsettings.json" />
10-
</ItemGroup>
8+
<ItemGroup>
9+
<None Remove="appsettings.json" />
10+
</ItemGroup>
1111

12-
<ItemGroup>
13-
<Content Include="appsettings.json">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</Content>
16-
</ItemGroup>
12+
<ItemGroup>
13+
<Content Include="appsettings.json">
14+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15+
</Content>
16+
</ItemGroup>
1717

18-
<ItemGroup>
19-
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
21-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
22-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
23-
</ItemGroup>
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
20+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
22+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
23+
</ItemGroup>
2424

25-
<ItemGroup>
26-
<ProjectReference Include="..\MassTransit.Extensions.Hosting.ActiveMq\MassTransit.Extensions.Hosting.ActiveMq.csproj" />
27-
<ProjectReference Include="..\MassTransit.Extensions.Hosting.AmazonSqs\MassTransit.Extensions.Hosting.AmazonSqs.csproj" />
28-
<ProjectReference Include="..\MassTransit.Extensions.Hosting.RabbitMq\MassTransit.Extensions.Hosting.RabbitMq.csproj" />
29-
<ProjectReference Include="..\MassTransit.Extensions.Hosting\MassTransit.Extensions.Hosting.csproj" />
30-
</ItemGroup>
25+
<ItemGroup>
26+
<PackageReference Include="WindowsAzure.ServiceBus" Version="4.1.11" />
27+
<PackageReference Include="MassTransit.AzureServiceBus" Version="5.1.5" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\MassTransit.Extensions.Hosting.ActiveMq\MassTransit.Extensions.Hosting.ActiveMq.csproj" />
32+
<ProjectReference Include="..\MassTransit.Extensions.Hosting.AmazonSqs\MassTransit.Extensions.Hosting.AmazonSqs.csproj" />
33+
<ProjectReference Include="..\MassTransit.Extensions.Hosting.AzureServiceBus\MassTransit.Extensions.Hosting.AzureServiceBus.csproj" />
34+
<ProjectReference Include="..\MassTransit.Extensions.Hosting.RabbitMq\MassTransit.Extensions.Hosting.RabbitMq.csproj" />
35+
<ProjectReference Include="..\MassTransit.Extensions.Hosting\MassTransit.Extensions.Hosting.csproj" />
36+
</ItemGroup>
3137

3238
</Project>

Example.ConsoleHost/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
using MassTransit.Extensions.Hosting;
2222
using MassTransit.Extensions.Hosting.ActiveMq;
2323
using MassTransit.Extensions.Hosting.AmazonSqs;
24+
using MassTransit.Extensions.Hosting.AzureServiceBus;
2425
using MassTransit.Extensions.Hosting.RabbitMq;
2526
using Microsoft.Extensions.Configuration;
2627
using Microsoft.Extensions.DependencyInjection;
2728
using Microsoft.Extensions.Hosting;
29+
using Microsoft.ServiceBus;
2830

2931
namespace Example.ConsoleHost
3032
{
@@ -129,6 +131,24 @@ private static void ConfigureServices(HostBuilderContext context, IServiceCollec
129131
});
130132
});
131133

134+
// AzureServiceBus
135+
busBuilder.UseAzureServiceBus(configuration.GetSection("MassTransit:AzureServiceBus"), hostBuilder =>
136+
{
137+
hostBuilder.UseServiceScope();
138+
139+
hostBuilder.UseTokenProvider(TokenProvider.CreateSimpleWebTokenProvider("web-token-example"));
140+
141+
hostBuilder.AddConfigurator(configureBus =>
142+
{
143+
configureBus.SelectBasicTier();
144+
});
145+
146+
hostBuilder.AddReceiveEndpoint("example-queue-5", endpointBuilder =>
147+
{
148+
endpointBuilder.AddConsumer<ExampleConsumer>();
149+
});
150+
});
151+
132152
});
133153
}
134154

Example.ConsoleHost/appsettings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"RegionSystemName": "us-east-1",
2424
"AccessKey": "access-key-example",
2525
"SecretKey": "secret-key-example"
26+
},
27+
28+
"AzureServiceBus": {
29+
"ConnectionName": "connection-name-5",
30+
"HostAddress": "sb://namespace.servicebus.windows.net/scope"
2631
}
2732

2833
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#region Copyright Preamble
2+
//
3+
// Copyright @ 2019 NCode Group
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
#endregion
17+
18+
using System.Collections.Generic;
19+
20+
namespace MassTransit.Extensions.Hosting.AzureServiceBus.Tests
21+
{
22+
/// <summary />
23+
public static class KeyValuePairFactory
24+
{
25+
/// <summary />
26+
public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey key, TValue value)
27+
{
28+
return new KeyValuePair<TKey, TValue>(key, value);
29+
}
30+
31+
}
32+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net461</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.1.0" />
11+
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
13+
<PackageReference Include="Moq" Version="4.10.1" />
14+
<PackageReference Include="xunit" Version="2.4.0" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\MassTransit.Extensions.Hosting.AzureServiceBus\MassTransit.Extensions.Hosting.AzureServiceBus.csproj" />
20+
</ItemGroup>
21+
22+
</Project>

0 commit comments

Comments
 (0)