AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/servicecontrol/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.

External Message Body Storage

Component:
ServiceControl

SQL Server and PostgreSQL storage separate large message bodies from the instance's database. The database stores message metadata and small text bodies; an external store holds larger bodies and every binary body. Configure an external store even if most messages have small bodies.

SQL-backed Error instances require an external store and do not start without one. SQL-backed Audit instances start without one, but then do not store large or binary bodies. RavenDB manages message body storage itself.

Storage providers

Choose one provider per instance and follow its configuration guide.

ProviderMessageBody/StorageType valueRequirementsConfiguration
File systemFileSystemA durable directory accessible to the instanceConfigure file system storage
Azure Blob StorageAzureBlobAn Azure Storage account and credentialsConfigure Azure Blob Storage
Amazon S3S3An S3 bucket and credentialsConfigure Amazon S3 storage

Configure the body store alongside SQL Server or PostgreSQL storage. Use the same settings during setup and normal operation. Error instance settings use the ServiceControl/ prefix, and Audit instance settings use the ServiceControl.Audit/ prefix. The ServiceControl Management Utility configures file system body storage for Error and Audit instances, in the MESSAGE BODY PATH of each instance. The PowerShell module configures any of these stores; see deploying an Error instance and deploying an Audit instance with PowerShell.

ServiceControl/MessageBody/StorageType

Added in version 7.0.0

The external storage provider used for message bodies.

ContextName
Environment variableSERVICECONTROL_MESSAGEBODY_STORAGETYPE
App config keyServiceControl/MessageBody/StorageType
SCMU fieldN/A
TypeDefault value
stringNone (required for SQL Server and PostgreSQL storage)

Valid values are FileSystem, AzureBlob, and S3. The ServiceControl Management Utility sets this to FileSystem. The PowerShell module sets it from -MessageBodyStorageType, which defaults to FileSystem.

ServiceControl.Audit/MessageBody/StorageType

Added in version 7.0.0

The external storage provider used for message bodies.

ContextName
Environment variableSERVICECONTROL_AUDIT_MESSAGEBODY_STORAGETYPE
App config keyServiceControl.Audit/MessageBody/StorageType
SCMU fieldN/A
TypeDefault value
stringNone

Valid values are FileSystem, AzureBlob, and S3. The ServiceControl Management Utility sets this to FileSystem. The PowerShell module sets it from -MessageBodyStorageType, which defaults to FileSystem.

When this setting is not set, an Audit instance using SQL Server or PostgreSQL storage has no external body store. It still starts, but it does not store bodies that are not text or that are larger than ServiceControl.Audit/MaxBodySizeToStore, and those bodies cannot be viewed in ServicePulse. Set it for every SQL-backed Audit instance.

Sharing a message body store

Audit instances delete the bodies of expired messages by hour or by day across the whole location, so an instance with a shorter retention period can delete bodies that another instance still needs, and those messages stay visible without their bodies. The Audit defaults (audit-bodies and audit-bodies/) differ from the Error defaults, but they are the same for every Audit instance, so set a different container or key prefix for each Audit instance.

The exception is processes that share a database: ingestion-only workers use their Error instance's body store, and Audit instances that share a database must also share one body store.

Inline storage and compression

A message body is stored in the database only when it is text and no larger than MaxBodySizeToStore. The following bodies go to the external store, whatever their size:

  • Bodies whose NServiceBus.ContentType header is missing, or does not contain text/, xml, or json, or contains binary
  • Bodies that have a Content-Encoding header, such as compressed payloads
  • Bodies that are not valid UTF-8 text, or that contain NUL characters

A text body larger than the limit is also stored externally, and its first MaxBodySizeToStore bytes are kept in the database so that full-text search can match it. When endpoints use a binary serializer, plan for every message body to be in the external store.

Bodies in the external store are compressed when they are at least MessageBody/MinCompressionSize bytes.

ServiceControl/MaxBodySizeToStore

Added in version 7.0.0

The maximum size, in bytes, of a text message body stored inline in the SQL database. Larger text bodies, and binary bodies of any size, are stored using the configured external storage provider. A larger text body also keeps its first MaxBodySizeToStore bytes in the database for full-text search. See what is stored where.

ContextName
Environment variableSERVICECONTROL_MAXBODYSIZETOSTORE
App config keyServiceControl/MaxBodySizeToStore
SCMU fieldN/A
TypeDefault value
int102400 (100 KB)

ServiceControl.Audit/MaxBodySizeToStore

A size limit, in bytes, for message bodies. Its effect depends on the storage type:

StorageEffect
RavenDBThe largest message body that the Audit instance stores. Larger bodies cannot be viewed in ServicePulse.
SQL Server or PostgreSQLThe largest text message body that is stored inline in the database. Larger text bodies, and bodies that are not text, are stored in the external message body store and can be viewed in ServicePulse. A larger text body also keeps its first MaxBodySizeToStore bytes in the database for full-text search. See what is stored where.
ContextName
Environment variableSERVICECONTROL_AUDIT_MAXBODYSIZETOSTORE
App config keyServiceControl.Audit/MaxBodySizeToStore
SCMU fieldN/A
TypeDefault value
int102400 (100 KB)

ServiceControl/MessageBody/MinCompressionSize

Added in version 7.0.0

The minimum message body size, in bytes, at which external message bodies are compressed.

ContextName
Environment variableSERVICECONTROL_MESSAGEBODY_MINCOMPRESSIONSIZE
App config keyServiceControl/MessageBody/MinCompressionSize
SCMU fieldN/A
TypeDefault value
int4096 (4 KB)

ServiceControl.Audit/MessageBody/MinCompressionSize

Added in version 7.0.0

The minimum message body size, in bytes, at which external message bodies are compressed.

ContextName
Environment variableSERVICECONTROL_AUDIT_MESSAGEBODY_MINCOMPRESSIONSIZE
App config keyServiceControl.Audit/MessageBody/MinCompressionSize
SCMU fieldN/A
TypeDefault value
int4096 (4 KB)

See the Error instance storage settings and Audit instance storage settings for the complete reference.

Operations

Treat the database and external body store as a pair, and back up and restore them together. Monitor body-store capacity and availability as well as database health.

An Error instance's retention process deletes a message's external body before it deletes the message's database record, starting with the oldest expired message. If body deletion fails, the affected records remain for a later sweep. After three failed runs in a row, the ServiceControl Retention custom check reports the failure in ServicePulse.

Audit instances delete the external bodies of each expired hour (SQL Server) or day (PostgreSQL) before removing the corresponding database records. If the body store fails, the records stay and the next retention run tries again. Repeated failures are reported by the Audit retention custom check.

Because retention deletes bodies, the identity the instance runs as needs delete access to the body store as well as read and write access.

Changing the provider, directory, container, or bucket does not move existing message bodies. Do not use configuration changes as a migration procedure. For database choices, see the storage overview.

Related Articles