Skip to content

Commit 6b50cd8

Browse files
WilliamBZAkentdr
authored andcommitted
Move databus to claimcheck
1 parent 6bb14e0 commit 6b50cd8

23 files changed

+238
-12
lines changed

Snippets/DataBus/DataBus.sln

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.1.32210.238
4+
MinimumVisualStudioVersion = 15.0.26730.12
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBus_1", "DataBus_1\DataBus_1.csproj", "{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{2FFFC06C-64E4-4A61-B3A0-71B8B4EBF046}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {1B5B580D-6C24-43BE-AEAC-F310FBBF0D77}
23+
EndGlobalSection
24+
EndGlobal

Snippets/DataBus/DataBus_1/DataBus.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace DataBus
2+
{
3+
using NServiceBus.ClaimCheck.DataBus;
4+
5+
#region MessageWithLargePayload
6+
7+
public class MessageWithLargePayload
8+
{
9+
public string SomeProperty { get; set; }
10+
public DataBusProperty<byte[]> LargeBlob { get; set; }
11+
}
12+
13+
#endregion
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace DataBusConventions
2+
{
3+
using NServiceBus.ClaimCheck.DataBus;
4+
5+
#region MessageWithLargePayloadUsingConvention
6+
7+
public class MessageWithLargePayload
8+
{
9+
public string SomeProperty { get; set; }
10+
public byte[] LargeBlobDataBus { get; set; }
11+
}
12+
13+
#endregion
14+
15+
class Usage
16+
{
17+
Usage(NServiceBus.EndpointConfiguration endpointConfiguration)
18+
{
19+
#region DefineMessageWithLargePayloadUsingConvention
20+
21+
var conventions = endpointConfiguration.Conventions();
22+
conventions.DefiningDataBusPropertiesAs(
23+
property => property.Name.EndsWith("DataBus"));
24+
25+
#endregion
26+
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="NServiceBus.Claimcheck.DataBus" Version="1.*" />
13+
</ItemGroup>
14+
15+
</Project>

components/components.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
NugetOrder:
1717
- NServiceBus.MessageInterfaces
1818

19+
- Key: DataBus
20+
Name: DataBus
21+
DocsUrl: /nservicebus/messaging/databus
22+
GitHubOwner: Particular
23+
Category: Databus
24+
ProjectUrl: https://github.com/Particular/NServiceBus.ClaimCheck.DataBus
25+
NugetOrder:
26+
- NServiceBus.ClaimCheck.DataBus
27+
1928
- Key: ABSDataBus
2029
Name: Azure Blob Storage Databus
2130
DocsUrl: /nservicebus/azure
@@ -27,7 +36,7 @@
2736

2837
- Key: BinaryDataBusSerializer
2938
Name: DataBus Binary Serializer
30-
DocsUrl: /nservicebus/messaging/databus/binary
39+
DocsUrl: /nservicebus/messaging/claimcheck/binary
3140
GitHubOwner: Particular
3241
Category: Databus
3342
ProjectUrl: https://github.com/Particular/NServiceBus.DataBus.BinarySerializer
@@ -155,7 +164,7 @@
155164

156165
- Key: FileShareDataBus
157166
Name: File Share Databus
158-
DocsUrl: /nservicebus/messaging/databus/file-share
167+
DocsUrl: /nservicebus/messaging/claimcheck/file-share
159168
GitHubOwner: Particular
160169
Category: Databus
161170
ProjectUrl: https://github.com/Particular/NServiceBus
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0 : 9

components/nugetAlias.txt

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CustomChecks4: ServiceControl.Plugin.Nsb4.CustomChecks
1919
CustomChecks5: ServiceControl.Plugin.Nsb5.CustomChecks
2020
CustomChecks6: ServiceControl.Plugin.Nsb6.CustomChecks
2121
CustomChecks: NServiceBus.CustomChecks
22+
DataBus: NServiceBus.ClaimCheck.DataBus
2223
Distributor: NServiceBus.Distributor.MSMQ
2324
Gateway: NServiceBus.Gateway
2425
GatewayRavenDB: NServiceBus.Gateway.RavenDB

menu/menu.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@
477477
- Url: nservicebus/messaging/databus
478478
Title: Data Bus
479479
Articles:
480-
- Url: nservicebus/messaging/databus/file-share
480+
- Url: nservicebus/messaging/claimcheck/file-share
481481
Title: File Share
482-
- Url: nservicebus/messaging/databus/azure-blob-storage
482+
- Url: nservicebus/messaging/claimcheck/azure-blob-storage
483483
Title: Azure Blob Storage
484-
- Url: nservicebus/messaging/databus/binary
484+
- Url: nservicebus/messaging/claimcheck/binary
485485
Title: DataBus binary serializer
486-
- Url: nservicebus/messaging/databus/custom
486+
- Url: nservicebus/messaging/claimcheck/custom
487487
Title: Customizing DataBus
488488
- Title: Hosting
489489
Articles:

nservicebus/messaging/databus/azure-blob-storage.md renamed to nservicebus/messaging/claimcheck/azure-blob-storage.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Azure Blob Storage Data Bus
33
summary: The Azure Blob Storage implementation of databus
44
reviewed: 2024-02-16
55
component: ABSDataBus
6+
redirects:
7+
- nservicebus/messaging/databus/azure-blog-storage
68
related:
79
- samples/databus/blob-storage-databus
810
- samples/databus/blob-storage-databus-cleanup-function

nservicebus/messaging/databus/binary/index.md renamed to nservicebus/messaging/claimcheck/binary/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: DataBus Binary Serializer
33
summary: A binary serializer for the data bus
44
component: BinaryDataBusSerializer
55
reviewed: 2024-02-16
6+
redirects:
7+
- nservicebus/messaging/databus/binary
68
related:
79
- samples/databus/file-share-databus
810
- samples/databus/custom-serializer

nservicebus/messaging/databus/custom.md renamed to nservicebus/messaging/claimcheck/custom.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
title: Customizing the data bus
33
summary: Demonstrates how to register and plug in a customized data bus implementation into an endpoint.
4-
component: Core
4+
component: DataBus
55
reviewed: 2024-02-16
66
redirects:
7-
- nservicebus/plugin-custom-databus
7+
- nservicebus/plugin-custom-databus
8+
- nservicebus/messaging/databus/custom
89
related:
910
- samples/databus/custom-serializer
1011
---

nservicebus/messaging/databus/file-share.md renamed to nservicebus/messaging/claimcheck/file-share.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: File Share Data Bus
33
summary: An implementation of data bus using file shares
44
reviewed: 2024-02-16
55
component: FileShareDataBus
6+
redirects:
7+
- nservicebus/messaging/databus/file-share
68
related:
79
- samples/databus/file-share-databus
810
---
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: NServiceBus DataBus feature
3+
summary: How to handle messages that are too large to be sent by a transport natively by using NServiceBus DataBus
4+
component: Databus
5+
reviewed: 2024-08-01
6+
redirects:
7+
- nservicebus/databus
8+
- samples/pipeline/stream-properties
9+
related:
10+
- samples/databus/file-share-databus
11+
- samples/databus/custom-serializer
12+
- samples/databus/blob-storage-databus
13+
---
14+
15+
Although messaging systems work best with small message sizes, some scenarios require sending binary large objects ([blobs](https://en.wikipedia.org/wiki/Binary_large_object)) data along with a message (also known as a [_Claim Check_](https://learn.microsoft.com/en-us/azure/architecture/patterns/claim-check)). For this purpose, NServiceBus has a `DataBus` feature to overcome the message size limitations imposed by the underlying transport.
16+
17+
## How it works
18+
19+
Instead of serializing the payload along with the rest of the message, the `DataBus` approach involves storing the payload in a separate location that both the sending and receiving parties can access, then putting the reference to that location in the message.
20+
21+
If the location is not available upon sending, the send operation will fail. When a message is received and the payload location is not available, the receive operation will fail too, resulting in the standard NServiceBus retry behavior, possibly resulting in the message being moved to the error queue if the error could not be resolved.
22+
23+
## Transport message size limits
24+
25+
The `DataBus` may be used to send messages which exceed the transport's message size limit, which is determined by the message size limit of the underlying queuing/storage technologies.
26+
27+
> [!NOTE]
28+
> Not all transports have message size limits and some technologies, such as Azure Service Bus, have increased over time. Current message size limits are stated in the documentation linked in the table below.
29+
30+
| Transport | Maximum size |
31+
| --------------------------------- | ------------:|
32+
| Amazon SQS | [256KB](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html) |
33+
| Amazon SQS (using S3) | [2GB](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html) |
34+
| Azure Storage Queues | [64KB](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted#capacity-and-quotas) |
35+
| Azure Service Bus (Standard tier) | [256KB](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted#capacity-and-quotas) |
36+
| Azure Service Bus (Premium tier) | [100MB](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support) |
37+
| RabbitMQ | Configured by [`max_message_size`](https://www.rabbitmq.com/configure.html#config-items) |
38+
| SQL Server | No limit |
39+
| Learning | No limit |
40+
| MSMQ | [4MB](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/msmq/ms711436(v=vs.85)#maximum-message-size) |
41+
42+
## Enabling the `DataBus`
43+
44+
See the individual `DataBus` implementations for details on enabling and configuring the `DataBus`.
45+
46+
- [File Share Data Bus](file-share.md)
47+
- [Azure Blob Storage Data Bus](azure-blob-storage.md)
48+
49+
## Cleanup
50+
51+
By default, blobs are stored with no set expiration. If messages have a [time to be received](/nservicebus/messaging/discard-old-messages.md) set, the `DataBus` will pass this along to the data bus storage implementation.
52+
53+
> [!NOTE]
54+
> The value used should be aligned with the [ServiceContol audit retention period](/servicecontrol/how-purge-expired-data.md) if it is required that `DataBus` blob keys in messages sent to the audit queue can still be fetched.
55+
56+
## Specifying `DataBus` properties
57+
58+
There are two ways to specify the message properties to be sent using the `DataBus`:
59+
60+
1. Using the `DataBusProperty<T>` type
61+
1. Message conventions
62+
63+
> [!NOTE]
64+
> `DataBus` properties must be top-level properties on a message class.
65+
66+
### Using `DataBusProperty<T>`
67+
68+
Set the type of the property to be sent over as `DataBusProperty<byte[]>`:
69+
70+
snippet: MessageWithLargePayload
71+
72+
### Using message conventions
73+
74+
NServiceBus also supports defining `DataBus` properties by convention. This allows data properties to be sent using the `DataBus` without using `DataBusProperty<T>`, thus removing the need for having a dependency on NServiceBus from the message types.
75+
76+
In the configuration of the endpoint include:
77+
78+
snippet: DefineMessageWithLargePayloadUsingConvention
79+
80+
Set the type of the property as `byte[]`:
81+
82+
snippet: MessageWithLargePayloadUsingConvention
83+
84+
partial: serialization
85+
86+
## `DataBus` attachments cleanup
87+
88+
The `DataBus` implementations each behave differently when cleaning up the physical attachments used to transfer the data properties.
89+
90+
### Why attachments are not removed by default
91+
92+
Automatically removing these attachments can cause problems in many situations. For example:
93+
94+
- The supported implementations do not participate in distributed transactions. If the message handler throws an exception and the transaction rolls back, the delete operation on the attachment cannot be rolled back. Therefore, when the message is retried, the attachment will no longer be present, causing additional problems.
95+
- The message can be deferred so that the file will be processed later. Removing the file after deferring the message, results in a message without the corresponding file.
96+
- Functional requirements might dictate the message to be available for a longer duration.
97+
- If the `DataBus` feature is used when publishing an event to multiple subscribers, neither the publisher nor any specific subscribing endpoint can determine when all subscribers have successfully processed the message, allowing the file to be cleaned up.
98+
- If message processing fails, it will be handled by the [recoverability feature](/nservicebus/recoverability/). This message can then be retried some period after that failure. The attachment files need to exist for that message to be re-processed correctly.
99+
100+
## Alternatives
101+
102+
> [!NOTE]
103+
> A combination of these techniques may be used.
104+
105+
- Use a different transport or different tier (e.g. Azure Service Bus _Premium_ instead of _Standard_).
106+
- Use message body compression, which works well on text-based payloads like XML and JSON or any payload (text or binary) that contains repetitive data.
107+
- The [message mutator sample](/samples/messagemutators/) demonstrates message body compression.
108+
- Use a more efficient serializer, such as a binary serializer.
109+
- A custom serializer can usually be implemented in only a few lines of code.
110+
- Some binary [serializers are maintained by the community](/nservicebus/community/#serializers).
111+
- Use [NServiceBus.Attachments](/nservicebus/community/#nservicebus-attachments) for unbounded binary payloads. The package is similar to the `DataBus`, but has some differences:
112+
- Read on demand: Attachments are only retrieved when read by a consumer.
113+
- Async enumeration: The package supports processing all data items using an `IAsyncEnumerable`.
114+
- No serialization: The serializer is not used, which may result in a significant reduction in memory usage.
115+
- Direct stream access: This makes the package more suitable for [binary large objects (blobs](https://en.wikipedia.org/wiki/Binary_large_object) since stream contents do not necessarily have to be loaded into memory before storing them or when retrieving them.
116+
117+
## Other considerations
118+
119+
### Monitoring and reliability
120+
121+
The storage location for `DataBus` blobs is critical to the operation of endpoints. As such, it should be as reliable as other infrastructure, such as the transport or persistence. It should also be monitored for errors and be actively maintained. Since messages cannot be sent or received when the storage location is unavailable, it may be necessary to stop endpoints when maintenance tasks occur.
122+
123+
### Auditing
124+
125+
The data stored in `DataBus` blobs may be considered part of an audit record. In these cases, the blobs should be archived alongside messages for as long as the audit record is required.

nservicebus/messaging/databus/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: NServiceBus DataBus feature
33
summary: How to handle messages that are too large to be sent by a transport natively by using NServiceBus DataBus
44
component: Core
5-
reviewed: 2024-02-16
5+
reviewed: 2024-08-01
66
redirects:
77
- nservicebus/databus
88
- samples/pipeline/stream-properties
@@ -45,8 +45,8 @@ The `DataBus` may be used to send messages which exceed the transport's message
4545

4646
See the individual `DataBus` implementations for details on enabling and configuring the `DataBus`.
4747

48-
- [File Share Data Bus](file-share.md)
49-
- [Azure Blob Storage Data Bus](azure-blob-storage.md)
48+
- [File Share Data Bus](/nservicebus/messaging/claimcheck/file-share.md)
49+
- [Azure Blob Storage Data Bus](/nservicebus/messaging/claimcheck/azure-blob-storage.md)
5050

5151
## Cleanup
5252

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
> [!WARNING]
2-
> The `DataBus` feature is available as a [dedicated NuGet package](/nservicebus/messaging/databus/). The API documented on this page will continue to work for NServiceBus Version 9 but it will hint about its upcoming obsoletion with the following warning: *The DataBus feature is released as a dedicated 'NServiceBus.ClaimCheck.DataBus' package.*.
2+
> The `DataBus` feature is available as a [dedicated NuGet package](/nservicebus/messaging/databus/). The API documented on this page will continue to work for NServiceBus Version 9 but it will hint about its upcoming obsoletion with the following warning: *The DataBus feature is released as a dedicated 'NServiceBus.ClaimCheck.DataBus' package.*.
3+
> The new documentation is [here](/nservicebus/messaging/claimcheck/).

0 commit comments

Comments
 (0)