Skip to content

Commit 98234d5

Browse files
committed
Update DataBus snippets to ClaimCheck
1 parent d194fdc commit 98234d5

File tree

12 files changed

+157
-136
lines changed

12 files changed

+157
-136
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace ClaimCheck_1.ClaimCheck.Conventions;
2+
3+
#region MessageWithLargePayloadUsingConvention
4+
5+
public class MessageWithLargePayload
6+
{
7+
public string SomeProperty { get; set; }
8+
public byte[] LargeBlobDataBus { get; set; }
9+
}
10+
11+
#endregion
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ClaimCheck_1.ClaimCheck.Conventions;
2+
3+
using NServiceBus;
4+
using NServiceBus.ClaimCheck;
5+
6+
class Usage
7+
{
8+
Usage(EndpointConfiguration endpointConfiguration)
9+
{
10+
#region DefineMessageWithLargePayloadUsingConvention
11+
12+
var conventions = endpointConfiguration.Conventions();
13+
conventions.DefiningClaimCheckPropertiesAs(
14+
property => property.Name.EndsWith("DataBus"));
15+
16+
#endregion
17+
}
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
namespace ClaimCheck_1.ClaimCheck.Custom;
2+
3+
using System;
4+
using System.IO;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using NServiceBus.ClaimCheck;
8+
9+
#region CustomDataBus
10+
11+
class CustomClaimCheck :
12+
IClaimCheck
13+
{
14+
public Task<Stream> Get(string key, CancellationToken cancellationToken)
15+
{
16+
Stream stream = File.OpenRead("blob.dat");
17+
return Task.FromResult(stream);
18+
}
19+
20+
public async Task<string> Put(Stream stream, TimeSpan timeToBeReceived, CancellationToken cancellationToken)
21+
{
22+
await using var destination = File.OpenWrite("blob.dat");
23+
await stream.CopyToAsync(destination, 81920, cancellationToken);
24+
return "the-key-of-the-stored-file-such-as-the-full-path";
25+
}
26+
27+
public Task Start(CancellationToken cancellationToken)
28+
{
29+
return Task.CompletedTask;
30+
}
31+
}
32+
33+
#endregion
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace ClaimCheck_1.ClaimCheck.Custom;
2+
3+
using System;
4+
using NServiceBus.ClaimCheck;
5+
6+
#region CustomDataBusDefinition
7+
class CustomClaimCheckDefinition : ClaimCheckDefinition
8+
{
9+
protected override Type ProvidedByFeature()
10+
=> typeof(CustomClaimCheckFeature);
11+
}
12+
#endregion
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ClaimCheck_1.ClaimCheck.Custom;
2+
3+
using Microsoft.Extensions.DependencyInjection;
4+
using NServiceBus.ClaimCheck;
5+
using NServiceBus.Features;
6+
7+
#region CustomDataBusFeature
8+
9+
class CustomClaimCheckFeature : Feature
10+
{
11+
public CustomClaimCheckFeature()
12+
=> DependsOn<ClaimCheckFeature>();
13+
14+
protected override void Setup(FeatureConfigurationContext context)
15+
=> context.Services.AddSingleton<IClaimCheck, CustomClaimCheck>();
16+
}
17+
18+
#endregion
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace ClaimCheck_1.ClaimCheck.Custom;
2+
3+
using System;
4+
using System.IO;
5+
using NServiceBus;
6+
using NServiceBus.ClaimCheck;
7+
8+
class Usage
9+
{
10+
Usage(EndpointConfiguration endpointConfiguration)
11+
{
12+
#region PluginCustomDataBus
13+
14+
endpointConfiguration.UseClaimCheck(svc => new CustomClaimCheck(), new SystemJsonClaimCheckSerializer());
15+
16+
#endregion
17+
18+
#region SpecifyingSerializer
19+
20+
endpointConfiguration.UseClaimCheck<FileShareClaimCheck, SystemJsonClaimCheckSerializer>();
21+
22+
#endregion
23+
24+
#region SpecifyingDeserializer
25+
26+
endpointConfiguration.UseClaimCheck<FileShareClaimCheck, SystemJsonClaimCheckSerializer>()
27+
.AddDeserializer<BsonClaimCheckSerializer>();
28+
29+
#endregion
30+
}
31+
32+
class BsonClaimCheckSerializer : IClaimCheckSerializer
33+
{
34+
public void Serialize(object databusProperty, Stream stream)
35+
{
36+
}
37+
38+
public object Deserialize(Type propertyType, Stream stream)
39+
{
40+
return default;
41+
}
42+
43+
public string ContentType { get; }
44+
}
45+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using NServiceBus;
2+
using NServiceBus.ClaimCheck;
3+
4+
namespace ClaimCheck_1.ClaimCheck.DataBusProperty
5+
{
6+
#region MessageWithLargePayload
7+
8+
public class MessageWithLargePayload
9+
{
10+
public string SomeProperty { get; set; }
11+
public ClaimCheckProperty<byte[]> LargeBlob { get; set; }
12+
}
13+
14+
#endregion
15+
}

Snippets/DataBus/DataBus_1/DataBus_1.csproj renamed to Snippets/DataBus/ClaimCheck_1/ClaimCheck_1.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5+
<RootNamespace>ClaimCheck_1</RootNamespace>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<FrameworkReference Include="Microsoft.AspNetCore.App" />
910
</ItemGroup>
1011

1112
<ItemGroup>
12-
<PackageReference Include="NServiceBus.Claimcheck.DataBus" Version="1.*" />
13+
<PackageReference Include="NServiceBus" Version="9.*" />
14+
<PackageReference Include="NServiceBus.ClaimCheck" Version="1.0.0-alpha.1" />
1315
</ItemGroup>
1416

15-
</Project>
17+
</Project>

Snippets/DataBus/DataBus.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 17
33
VisualStudioVersion = 17.1.32210.238
44
MinimumVisualStudioVersion = 15.0.26730.12
5-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBus_1", "DataBus_1\DataBus_1.csproj", "{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClaimCheck_1", "ClaimCheck_1\ClaimCheck_1.csproj", "{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}"
66
EndProject
77
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core_9", "Core_9\Core_9.csproj", "{5822CCDD-8708-46EA-A74E-3D60A68752F6}"
88
EndProject

Snippets/DataBus/DataBus_1/CustomDataBus.cs

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)