Table of Contents

Struct NatsMsg<T>

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll

NATS message structure as defined by the protocol.

public readonly record struct NatsMsg<T> : INatsMsg<T>, IEquatable<NatsMsg<T>>

Type Parameters

T

Specifies the type of data that may be sent to the NATS Server.

Implements
Inherited Members
Extension Methods

Remarks

Connection property is used to provide reply functionality.

Message size is calculated using the same method NATS server uses:

int size = subject.Length + replyTo.Length + headers.Length + payload.Length;

Constructors

NatsMsg(string, string?, int, NatsHeaders?, T?, INatsConnection?)

NATS message structure as defined by the protocol.

Properties

Connection

NATS connection this message is associated to.

Data

Serializable data object.

Error

Any errors (generally serialization errors) encountered while processing the message.

Headers

Pass additional information using name-value pairs.

ReplyTo

The reply subject that subscribers can use to send a response back to the publisher/requester.

Size

Message size in bytes.

Subject

The destination subject to publish to.

Methods

EnsureSuccess()

Throws an exception if the message contains any errors (generally serialization errors).

ReplyAsync(NatsHeaders?, string?, NatsPubOpts?, CancellationToken)

Reply with an empty message.

ReplyAsync<TReply>(NatsMsg<TReply>, INatsSerialize<TReply>?, NatsPubOpts?, CancellationToken)

Reply to this message.

ReplyAsync<TReply>(TReply, NatsHeaders?, string?, INatsSerialize<TReply>?, NatsPubOpts?, CancellationToken)

Reply to this message.