-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
765e449
commit 5563572
Showing
20 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/CrossVersionPubSub.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35527.113 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{06CB90E0-85AD-4F8C-9D5C-D008EB63FA3A}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublisherV4", "PublisherV4\PublisherV4.csproj", "{29F1787F-7118-48F6-B4A3-E6C45E23956C}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PublisherV5", "PublisherV5\PublisherV5.csproj", "{38C77DC9-51F3-421D-BBE6-3DE8508AEE15}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriberV4", "SubscriberV4\SubscriberV4.csproj", "{E95F1759-40E5-4B72-B3AE-868CB538F5DA}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriberV5", "SubscriberV5\SubscriberV5.csproj", "{3713A7D0-E843-4FF1-9688-165F2345CFC5}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{06CB90E0-85AD-4F8C-9D5C-D008EB63FA3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{06CB90E0-85AD-4F8C-9D5C-D008EB63FA3A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{06CB90E0-85AD-4F8C-9D5C-D008EB63FA3A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{06CB90E0-85AD-4F8C-9D5C-D008EB63FA3A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{29F1787F-7118-48F6-B4A3-E6C45E23956C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{29F1787F-7118-48F6-B4A3-E6C45E23956C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{29F1787F-7118-48F6-B4A3-E6C45E23956C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{29F1787F-7118-48F6-B4A3-E6C45E23956C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{38C77DC9-51F3-421D-BBE6-3DE8508AEE15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{38C77DC9-51F3-421D-BBE6-3DE8508AEE15}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{38C77DC9-51F3-421D-BBE6-3DE8508AEE15}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{38C77DC9-51F3-421D-BBE6-3DE8508AEE15}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E95F1759-40E5-4B72-B3AE-868CB538F5DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E95F1759-40E5-4B72-B3AE-868CB538F5DA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E95F1759-40E5-4B72-B3AE-868CB538F5DA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E95F1759-40E5-4B72-B3AE-868CB538F5DA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3713A7D0-E843-4FF1-9688-165F2345CFC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3713A7D0-E843-4FF1-9688-165F2345CFC5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3713A7D0-E843-4FF1-9688-165F2345CFC5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3713A7D0-E843-4FF1-9688-165F2345CFC5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {071F7DAC-CB22-4DB9-86FF-4CFC7D3172B5} | ||
EndGlobalSection | ||
EndGlobal |
38 changes: 38 additions & 0 deletions
38
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV4/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
|
||
namespace PublisherV4 | ||
{ | ||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Console.WriteLine("Publisher 1 running Azure Service Bus transport V4"); | ||
var builder = Host.CreateApplicationBuilder(args); | ||
|
||
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); | ||
builder.Logging.AddConsole(); | ||
|
||
var endpointConfiguration = new EndpointConfiguration("Publisher1"); | ||
|
||
var connectionString = builder.Configuration.GetConnectionString("AzureServiceBusConnectionString"); | ||
var routing = endpointConfiguration.UseTransport(new AzureServiceBusTransport(connectionString)); | ||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
|
||
// Operational scripting: https://docs.particular.net/transports/azure-service-bus/operational-scripting | ||
endpointConfiguration.EnableInstallers(); | ||
|
||
builder.UseNServiceBus(endpointConfiguration); | ||
|
||
builder.Services.AddHostedService<PublisherWorker>(); | ||
|
||
var host = builder.Build(); | ||
await host.RunAsync(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV4/PublisherV4.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<LangVersion>13.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="4.*" /> | ||
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" /> | ||
</ItemGroup> | ||
|
||
</Project> |
36 changes: 36 additions & 0 deletions
36
...azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV4/PublisherWorker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
using Shared; | ||
|
||
namespace PublisherV4 | ||
{ | ||
public class PublisherWorker : BackgroundService | ||
{ | ||
private readonly IMessageSession messageSession; | ||
private readonly ILogger<PublisherWorker> logger; | ||
|
||
public PublisherWorker(IMessageSession messageSession, ILogger<PublisherWorker> logger) | ||
{ | ||
this.messageSession = messageSession; | ||
this.logger = logger; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
try | ||
{ | ||
await messageSession.Publish(new MyEvent()); | ||
|
||
logger.LogInformation("Published MyEvent"); | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
// graceful shutdown | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV4/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
}, | ||
"ConnectionStrings": { | ||
"AzureServiceBusConnectionString": "<PLACEHOLDER>" | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV5/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
using Shared; | ||
|
||
namespace PublisherV5 | ||
{ | ||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Console.WriteLine("Publisher 2 running Azure Service Bus transport V5"); | ||
var builder = Host.CreateApplicationBuilder(args); | ||
|
||
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); | ||
builder.Logging.AddConsole(); | ||
|
||
var endpointConfiguration = new EndpointConfiguration("Publisher2"); | ||
|
||
var connectionString = builder.Configuration.GetConnectionString("AzureServiceBusConnectionString"); | ||
var topology = TopicTopology.MigrateFromSingleDefaultTopic(); | ||
topology.EventToMigrate<MyOtherEvent>(); | ||
var routing = endpointConfiguration.UseTransport(new AzureServiceBusTransport(connectionString, topology)); | ||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
|
||
// Operational scripting: https://docs.particular.net/transports/azure-service-bus/operational-scripting | ||
endpointConfiguration.EnableInstallers(); | ||
|
||
builder.UseNServiceBus(endpointConfiguration); | ||
|
||
builder.Services.AddHostedService<PublisherWorker>(); | ||
|
||
var host = builder.Build(); | ||
await host.RunAsync(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV5/PublisherV5.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<LangVersion>13.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="5.*-*" /> | ||
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" /> | ||
</ItemGroup> | ||
|
||
</Project> |
36 changes: 36 additions & 0 deletions
36
...azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV5/PublisherWorker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
using Shared; | ||
|
||
namespace PublisherV5 | ||
{ | ||
public class PublisherWorker : BackgroundService | ||
{ | ||
private readonly IMessageSession messageSession; | ||
private readonly ILogger<PublisherWorker> logger; | ||
|
||
public PublisherWorker(IMessageSession messageSession, ILogger<PublisherWorker> logger) | ||
{ | ||
this.messageSession = messageSession; | ||
this.logger = logger; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
try | ||
{ | ||
await messageSession.Publish(new MyOtherEvent()); | ||
|
||
logger.LogInformation("Published MyOtherEvent"); | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
// graceful shutdown | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/PublisherV5/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
}, | ||
"ConnectionStrings": { | ||
"AzureServiceBusConnectionString": "<PLACEHOLDER>" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/Shared/MyEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NServiceBus; | ||
|
||
namespace Shared | ||
{ | ||
public class MyEvent : IEvent | ||
{ | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/Shared/MyOtherEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using NServiceBus; | ||
|
||
namespace Shared; | ||
|
||
public class MyOtherEvent : IEvent | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/Shared/Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<LangVersion>13.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NServiceBus" Version="9.*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
23 changes: 23 additions & 0 deletions
23
...-service-bus-netstandard/cross-version-pub-sub/ASBS_5/SubscriberV4/MyOtherEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
using Shared; | ||
|
||
namespace SubscriberV4 | ||
{ | ||
public class MyOtherEventHandler : IHandleMessages<MyOtherEvent> | ||
{ | ||
private readonly ILogger<MyOtherEventHandler> logger; | ||
|
||
public MyOtherEventHandler(ILogger<MyOtherEventHandler> logger) | ||
{ | ||
this.logger = logger; | ||
} | ||
|
||
public Task Handle(MyOtherEvent message, IMessageHandlerContext context) | ||
{ | ||
logger.LogInformation("Received MyOtherEvent"); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
samples/azure-service-bus-netstandard/cross-version-pub-sub/ASBS_5/SubscriberV4/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using NServiceBus; | ||
using Shared; | ||
|
||
namespace SubscriberV4 | ||
{ | ||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Console.WriteLine("Subscriber 2 running Azure Service Bus transport V4"); | ||
var builder = Host.CreateApplicationBuilder(args); | ||
|
||
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); | ||
builder.Logging.AddConsole(); | ||
|
||
var endpointConfiguration = new EndpointConfiguration("Subscriber2"); | ||
|
||
var connectionString = builder.Configuration.GetConnectionString("AzureServiceBusConnectionString"); | ||
var routing = endpointConfiguration.UseTransport(new AzureServiceBusTransport(connectionString)); | ||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
|
||
// Operational scripting: https://docs.particular.net/transports/azure-service-bus/operational-scripting | ||
endpointConfiguration.EnableInstallers(); | ||
|
||
builder.UseNServiceBus(endpointConfiguration); | ||
|
||
var host = builder.Build(); | ||
await host.RunAsync(); | ||
} | ||
} | ||
} |
Oops, something went wrong.