File Share Data Bus

NuGet Package NServiceBus (5.x)
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

The file share data bus allows large properties to be transferred via a Windows file share.

This implementation leverages both serialization and headers to provide its functionality.


var dataBus = busConfiguration.UseDataBus<FileShareDataBus>();

Cleanup strategy

FileShareDataBus does not remove physical attachments once the message has been processed.

The business requirements can indicate how a message and its corresponding file should be processed and when the files can safely be removed. One strategy to deal with these attachments is to set up a cleanup policy which removes any attachments after a certain number of days have passed based on business Service Level Agreements.

The file location used by the data bus is set during configuration time.

var dataBus = busConfiguration.UseDataBus<FileShareDataBus>();

This same location should be used when performing the cleanup.

For example, this path can be used in a Handler for a message containing data bus properties.

public class Handler :
    IBus bus;

    public Handler(IBus bus)
        this.bus = bus;

    public void Handle(MessageWithLargePayload message)
        var filePath = Path.Combine(@"\\share\databus_attachments\", message.LargeBlob.Key);
        var removeAttachment = new RemoveDatabusAttachment
            FilePath = filePath
        bus.Defer(TimeSpan.FromDays(30), removeAttachment);

    public void Handle(RemoveDatabusAttachment message)
        var filePath = message.FilePath;
        // Code to clean up



Last modified