AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/nservicebus/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Customizing the data bus

Component:
DataBus
NuGet Package:
NServiceBus.ClaimCheck 2.x
Target Version:
NServiceBus 10.x

Endpoints support sending and receiving large chunks of data via the data bus.

It is possible to create a custom data bus implementation. This is done by using the Features extension.

Implement the IDataBus interface

This new class will provide the custom implementations for the Get and Put methods for the data bus.

class CustomClaimCheck :
    IClaimCheck
{
    public Task<Stream> Get(string key, CancellationToken cancellationToken)
    {
        Stream stream = File.OpenRead("blob.dat");
        return Task.FromResult(stream);
    }

    public async Task<string> Put(Stream stream, TimeSpan timeToBeReceived, CancellationToken cancellationToken)
    {
        await using var destination = File.OpenWrite("blob.dat");
        await stream.CopyToAsync(destination, 81920, cancellationToken);
        return "the-key-of-the-stored-file-such-as-the-full-path";
    }

    public Task Start(CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }
}

This new implementation needs to be registered as a new feature.

Define a feature

Define a new feature that registers the custom data bus implementation class.

class CustomClaimCheckFeature : Feature
{
    public CustomClaimCheckFeature()
        => DependsOn<ClaimCheck>();

    protected override void Setup(FeatureConfigurationContext context)
        => context.Services.AddSingleton<IClaimCheck, CustomClaimCheck>();
}

Define a DataBusDefinition

Define a new class that inherits from the DataBusDefinition class.

class CustomClaimCheckDefinition : ClaimCheckDefinition
{
    protected override void EnableFeature(SettingsHolder settings) => settings.EnableFeature<CustomClaimCheckFeature>();
}

Configure the endpoint

Configure the endpoint to use the custom data bus implementation instead of the default data bus:

endpointConfiguration.UseClaimCheck(svc => new CustomClaimCheck(), new SystemJsonClaimCheckSerializer());

List of Samples