Skip to content

Commit 3070f2e

Browse files
authored
Udpate blob-storage-databus to NServiceBus 10 (#7519)
1 parent 075491b commit 3070f2e

File tree

10 files changed

+197
-1
lines changed

10 files changed

+197
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29728.190
5+
MinimumVisualStudioVersion = 15.0.26730.12
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sender", "Sender\Sender.csproj", "{58F9345A-2622-4EC5-9B74-1DF74E639FB3}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Receiver", "Receiver\Receiver.csproj", "{44A0ED15-DEC7-48BA-810E-A08FFD0DBA46}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{5B1F434B-952F-43B8-A10D-BBB622403971}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{58F9345A-2622-4EC5-9B74-1DF74E639FB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{58F9345A-2622-4EC5-9B74-1DF74E639FB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{44A0ED15-DEC7-48BA-810E-A08FFD0DBA46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{44A0ED15-DEC7-48BA-810E-A08FFD0DBA46}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{5B1F434B-952F-43B8-A10D-BBB622403971}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{5B1F434B-952F-43B8-A10D-BBB622403971}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
EndGlobalSection
24+
GlobalSection(SolutionProperties) = preSolution
25+
HideSolutionNode = FALSE
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.Extensions.Logging;
3+
using NServiceBus;
4+
5+
#region MessageWithLargePayloadHandler
6+
7+
public class MessageWithLargePayloadHandler(ILogger<MessageWithLargePayloadHandler> logger) :
8+
IHandleMessages<MessageWithLargePayload>
9+
{
10+
11+
public Task Handle(MessageWithLargePayload message, IMessageHandlerContext context)
12+
{
13+
logger.LogInformation("Message received. Description: '{Description}'. Size of payload property: {PayloadSize} Bytes", message.Description, message.LargePayload.Value.Length);
14+
return Task.CompletedTask;
15+
}
16+
}
17+
18+
#endregion
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using Azure.Storage.Blobs;
3+
using Microsoft.Extensions.Hosting;
4+
using NServiceBus;
5+
using NServiceBus.ClaimCheck;
6+
7+
Console.Title = "Receiver";
8+
var builder = Host.CreateApplicationBuilder(args);
9+
10+
var endpointConfiguration = new EndpointConfiguration("Samples.AzureBlobStorageDataBus.Receiver");
11+
12+
var blobServiceClient = new BlobServiceClient("UseDevelopmentStorage=true");
13+
14+
var claimCheck = endpointConfiguration.UseClaimCheck<AzureClaimCheck, SystemJsonClaimCheckSerializer>()
15+
.Container("testcontainer")
16+
.UseBlobServiceClient(blobServiceClient);
17+
18+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
19+
endpointConfiguration.UseTransport(new LearningTransport());
20+
endpointConfiguration.EnableInstallers();
21+
22+
Console.WriteLine("Press any key, the application is starting");
23+
Console.ReadKey();
24+
Console.WriteLine("Starting...");
25+
builder.UseNServiceBus(endpointConfiguration);
26+
27+
await builder.Build().RunAsync();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<LangVersion>preview</LangVersion>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.1" />
9+
<PackageReference Include="NServiceBus.DataBus.AzureBlobStorage" Version="7.0.0-alpha.1" />
10+
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="4.0.0-alpha.1" />
11+
<ProjectReference Include="..\Shared\Shared.csproj" />
12+
</ItemGroup>
13+
</Project>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Azure.Storage.Blobs;
4+
using NServiceBus;
5+
using NServiceBus.ClaimCheck;
6+
using Microsoft.Extensions.Hosting;
7+
using Microsoft.Extensions.DependencyInjection;
8+
9+
Console.Title = "Sender";
10+
var builder = Host.CreateApplicationBuilder(args);
11+
12+
var endpointConfiguration = new EndpointConfiguration("Samples.AzureBlobStorageDataBus.Sender");
13+
14+
#region ConfiguringDataBusLocation
15+
16+
var blobServiceClient = new BlobServiceClient("UseDevelopmentStorage=true");
17+
18+
var claimCheck = endpointConfiguration.UseClaimCheck<AzureClaimCheck, SystemJsonClaimCheckSerializer>()
19+
.Container("testcontainer")
20+
.UseBlobServiceClient(blobServiceClient);
21+
22+
#endregion
23+
24+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
25+
endpointConfiguration.UseTransport(new LearningTransport());
26+
endpointConfiguration.EnableInstallers();
27+
28+
Console.WriteLine("Press any key, the application is starting");
29+
Console.ReadKey();
30+
Console.WriteLine("Starting...");
31+
32+
builder.UseNServiceBus(endpointConfiguration);
33+
34+
var app = builder.Build();
35+
36+
await app.StartAsync();
37+
38+
var messageSession = app.Services.GetRequiredService<IMessageSession>();
39+
40+
Console.WriteLine("Press 'Enter' to send a large message (>4MB)");
41+
42+
while (true)
43+
{
44+
var key = Console.ReadKey();
45+
46+
if (key.Key == ConsoleKey.Enter)
47+
{
48+
await SendMessageLargePayload(messageSession);
49+
}
50+
else
51+
{
52+
break;
53+
}
54+
}
55+
56+
await app.StopAsync();
57+
58+
static async Task SendMessageLargePayload(IMessageSession messageSession)
59+
{
60+
Console.WriteLine("Sending message...");
61+
62+
#region SendMessageLargePayload
63+
64+
var message = new MessageWithLargePayload
65+
{
66+
Description = "This message contains a large payload that will be sent on the Azure data bus",
67+
LargePayload = new ClaimCheckProperty<byte[]>(new byte[1024 * 1024 * 5]) // 5MB
68+
};
69+
await messageSession.Send("Samples.AzureBlobStorageDataBus.Receiver", message);
70+
71+
#endregion
72+
73+
Console.WriteLine("Message sent.");
74+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<LangVersion>preview</LangVersion>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="NServiceBus.DataBus.AzureBlobStorage" Version="7.0.0-alpha.1" />
9+
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.1" />
10+
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="4.0.0-alpha.1" />
11+
<ProjectReference Include="..\Shared\Shared.csproj" />
12+
</ItemGroup>
13+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using NServiceBus;
2+
using NServiceBus.ClaimCheck;
3+
4+
#region MessageWithLargePayload
5+
6+
[TimeToBeReceived("00:03:00")]
7+
public class MessageWithLargePayload :
8+
ICommand
9+
{
10+
public ClaimCheckProperty<byte[]> LargePayload { get; set; }
11+
public string Description { get; set; }
12+
}
13+
14+
#endregion
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<LangVersion>preview</LangVersion>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.1" />
8+
<PackageReference Include="NServiceBus.ClaimCheck" Version="2.0.0-alpha.1" />
9+
</ItemGroup>
10+
</Project>

samples/databus/blob-storage-databus/ABSDataBus_7/prerelease.txt

Whitespace-only changes.

samples/databus/blob-storage-databus/sample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ related:
1010

1111
1. Start [Azurite Emulator](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio).
1212
1. Run the solution. Two console applications start.
13-
1. Find the `Sender` application by looking for the one with `Sender` in its path and press Enter in the window to send a message. A message has been sent that is larger than the allowed 4MB by MSMQ. NServiceBus sends it as an attachment via Azure storage, allowing it to reach the `Receiver` application.
13+
1. Find the `Sender` application by looking for the one with `Sender` in its path and press Enter in the window to send a message. A message has been sent that is larger than the allowed 4MB by the transport. NServiceBus sends it as an attachment via Azure storage, allowing it to reach the `Receiver` application.
1414

1515
## Code walk-through
1616

0 commit comments

Comments
 (0)