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.

Child containers

Component:
NServiceBus
NuGet Package:
NServiceBus 10.x

Child containers are a snapshot of the main container providing an additional instance lifetime scope.

Child container scope in NServiceBus

NServiceBus creates a child container for each transport message that is received. During message processing, all InstancePerUnitOfWork scoped instances that are created are resolved as singletons within the context of the same message. This is helpful to support the sharing of database sessions and other resources with lifetimes specific to the processed message.

Objects can be configured in a child container scope using the scoped lifetime:

endpointConfiguration.RegisterComponents(
    registration: components =>
    {
        components.AddScoped<InstancePerUnitOfWork>();
    });

Deterministic disposal

Child containers automatically dispose all IDisposable instances created with InstancePerUnitOfWork lifetime once the message is processed. This is useful for managing things like database sessions which must be disposed of properly.