Skip to main content
Table of Contents

Class BusEnvelopeJsonGuard

Namespace
Stratara.Abstractions.Messaging
Assembly
Stratara.Abstractions.dll

Static helpers that enforce BusEnvelopeJsonOptions limits at the boundary between the message-bus transport and the JSON deserialiser. Implementations of IMessageBus and command-dispatch workers call into this guard before invoking JsonSerializer so the deserialiser is never handed an over-large or over-deeply-nested payload.

public static class BusEnvelopeJsonGuard
Inheritance
BusEnvelopeJsonGuard
Inherited Members

Methods

CreateOptions(int)

Builds a JsonSerializerOptions instance with MaxDepth pinned to maxDepth. Other options stay at the System.Text.Json defaults so the wire format remains compatible with payloads serialised via the framework's standard JSON path.

public static JsonSerializerOptions CreateOptions(int maxDepth)

Parameters

maxDepth int

Maximum allowed nesting depth.

Returns

JsonSerializerOptions

A new JsonSerializerOptions instance with the configured depth limit.

EnsureWithinSizeLimit(int, int, string)

Throws JsonException when byteLength exceeds maxBytes; otherwise returns without effect.

public static void EnsureWithinSizeLimit(int byteLength, int maxBytes, string source)

Parameters

byteLength int

Length of the raw payload, in bytes.

maxBytes int

Configured maximum allowed payload size.

source string

Short descriptor included in the exception message — typically a topic or queue name — to aid diagnosis when a payload is rejected.

Exceptions

JsonException

The payload exceeds the configured limit.