Getting Started

Learning Transport

NuGet Package: NServiceBus (7.x)

The Learning Transport simulates queuing infrastructure by storing all message actions in the local file system. All files and directories are relative to the current solution directory.

The Learning Transport and Learning Persistence are not for production use. They are designed for short term learning and experimentation purposes. It should also not be used for longer-term development, i.e. the same transport and persistence used in production should be used in development and debug scenarios. Select a production transport and persistence before developing features. Do not use the learning transport or learning persistence to perform any kind of performance analysis.

Added in Version 6.3.

Some recommended use cases are:

  • Learning/Experimenting with NServiceBus features.
  • Building a spike or demo.
  • Reproducing a bug that is not related to a production transport, for example when raising a support case.

ServiceControl (and therefore ServicePulse and ServiceInsight) are only supported for demonstration purposes through use of the Platform Sample package.

Transport at a glance

TransactionsNone, ReceiveOnly, SendsWithAtomicReceive
Large message bodiesLearningTransport can handle arbitrary message size within available resources
Scale-outCompeting consumer
Scripted DeploymentNot supported
InstallersNot supported, the transport always create the required folder structure
Native integrationNot supported

Publish and subscribe

The learning transport simulates a multicast transport, which means that routing configuration isn't needed in order to publish events. See the native publish/subscribe documentation for further details.



Transactions and delivery guarantees

The transport supports the following Transport Transaction Modes:

  • Sends atomic with Receive (Default)
  • Receive Only
  • Unreliable (Transactions Disabled)


By default the transport runs with concurrency limited to 1. See the tuning for details on how to configure concurrency levels.

Production transports will run with higher concurrency setting by default

Storage Directory

By default all data is stored in a .learningtransport directory. The endpoint will traverse the folder hierarchy upwards in search for a .learningtransport directory or create one at the solution root folder if no matching folder has been found before.

To manually configure the storage location:

var transport = endpointConfiguration.UseTransport<LearningTransport>();
When using source control the storage directory should be excluded and never committed.

Payload size restriction

To simulate a real transport, the serialized message size supported by the learning transport is limited to 64 kB. To remove this restriction:

var transport = endpointConfiguration.UseTransport<LearningTransport>();

File System Structure

Subscription metadata

Native publish and subscribe is simulated by storing subscriber metadata in a .events folder in the root storage directory. Subscribers will write their address to a file named {storage directory}\.events\{message type fullname}\{endpointname}.subscription. Publishers will send copies of each published event to all registered subscribers.

Message File Types

Body File

The serialized contents of a message.

  • Serialization is done using the configured Serializer.
  • File convention is [MessageId].body.txt.

Metadata File

A serialized representation of a messages metadata.

  • First line is the path to the Message Body File.
  • Remaining lines are the json serialized headers of the message.
  • File convention is [MessageId].metadata.txt.

Error Directory

When a message fails processing both its metadata and body files will be moved to the "error" directory. The name of the directory will be derived from configured error queue address. The default error queue name, and hence directory name, is "error".

Endpoint Structure

Each endpoint will have a corresponding directory under .learningtransport with the following structure:

Metadata files

Each incoming messages will have a corresponding Metadata File at the root of the endpoint directory.

.bodies (directory)

Each incoming messages will have a corresponding Body in this directory.

.delayed (directory)

Used to store messages that have been send with a Delayed Delivery. One directory per time stamp (of a second granularity) with the format yyyyMMddHHmmss. Each timestamp directory can contain multiple Metadata Files.

.pending (directory)

Transaction directory used to mark a message as being processed. Also prevents duplicate processing.

.committed (directory)

Used to temporarily store outgoing message that are sent during the processing of another message.

Related Articles

Last modified