NATS .NET Client  1.1.4
The NATS.io .NET C# Client
NATS.Client.Msg Class Reference

Inherited by NATS.Client.JetStream.JetStreamMsg.

Public Member Functions

 Msg ()
 
 Msg (string subject, string reply, MsgHeader header, byte[] data)
 
 Msg (string subject, MsgHeader header, byte[] data)
 
 Msg (string subject, string reply, byte[] data)
 
 Msg (string subject, byte[] data)
 
 Msg (string subject)
 
void AssignData (byte[] data)
 
void Respond (byte[] data)
 
override string ToString ()
 
virtual void Ack ()
 
virtual void AckSync (int timeout)
 
virtual void Nak ()
 
virtual void NakWithDelay (Duration nakDelay)
 
virtual void NakWithDelay (long nakDelayMillis)
 
virtual void Term ()
 
virtual void InProgress ()
 

Properties

string Subject [get, set]
 
string Reply [get, set]
 
byte[] Data [get, set]
 
ISubscription ArrivalSubcription [get]
 
ISubscription ArrivalSubscription [get]
 
MsgHeader Header [get, set]
 
bool HasHeaders [get]
 
MsgStatus Status [get]
 
bool HasStatus [get]
 
virtual JetStream.MetaData MetaData [get]
 
AckType LastAck [get]
 
virtual bool IsJetStream [get]
 
long ConsumeByteCount [get]
 

Detailed Description

A NATS message is an object encapsulating a subject, optional reply payload, optional header, and subscription information, sent or received by the client application.

Constructor & Destructor Documentation

◆ Msg() [1/5]

NATS.Client.Msg.Msg ( string  subject,
string  reply,
MsgHeader  header,
byte[]  data 
)

Initializes a new instance of the Msg class with a subject, reply, header, and data.

Parameters
subjectSubject of the message.
replyA reply subject, or null.
headerMessage headers or null.
dataA byte array containing the message payload.

◆ Msg() [2/5]

NATS.Client.Msg.Msg ( string  subject,
MsgHeader  header,
byte[]  data 
)

Initializes a new instance of the Msg class with a subject, header, and data.

Parameters
subjectSubject of the message.
headerMessage headers or null.
dataA byte array containing the message payload.

◆ Msg() [3/5]

NATS.Client.Msg.Msg ( string  subject,
string  reply,
byte[]  data 
)

Initializes a new instance of the Msg class with a subject, reply, and data.

Parameters
subjectSubject of the message.
replyA reply subject, or null.
dataA byte array containing the message payload.

◆ Msg() [4/5]

NATS.Client.Msg.Msg ( string  subject,
byte[]  data 
)

Initializes a new instance of the Msg class with a subject and data.

Parameters
subjectSubject of the message.
dataA byte array containing the message payload.

◆ Msg() [5/5]

NATS.Client.Msg.Msg ( string  subject)

Initializes a new instance of the Msg class with a subject and no data.

Parameters
subjectSubject of the message.

Member Function Documentation

◆ Ack()

virtual void NATS.Client.Msg.Ack ( )
virtual

Acknowledges a JetStream messages received from a Consumer, indicating the message will not be resent.

This is a NOOP for standard NATS messages.

◆ AckSync()

virtual void NATS.Client.Msg.AckSync ( int  timeout)
virtual

Acknowledges a JetStream message received from a Consumer, indicating the message should not be received again later. A timeout of zero does not confirm the acknowledgement.

Parameters
timeoutthe duration to wait for an ack confirmation

This is a NOOP for standard NATS messages.

◆ AssignData()

void NATS.Client.Msg.AssignData ( byte[]  data)

Assigns the data of the message.

This is a direct assignment, to avoid expensive copy operations. A change to the passed byte array will be changed in the message.

The calling application is responsible for the data integrity in the message.

Parameters
dataa bytes buffer of data.

◆ InProgress()

virtual void NATS.Client.Msg.InProgress ( )
virtual

Indicates that this message is being worked on and reset redelivery timer in the server.

This is a NOOP for standard NATS messages.

◆ Nak()

virtual void NATS.Client.Msg.Nak ( )
virtual

Acknowledges a JetStream message has been received but indicates that the message is not completely processed and should be sent again later.

This is a NOOP for standard NATS messages.

◆ NakWithDelay() [1/2]

virtual void NATS.Client.Msg.NakWithDelay ( Duration  nakDelay)
virtual

Acknowledges a JetStream message has been received but indicates that the message is not completely processed and should be sent again later, after at least the delay amount.

This is a NOOP for standard NATS messages.

◆ NakWithDelay() [2/2]

virtual void NATS.Client.Msg.NakWithDelay ( long  nakDelayMillis)
virtual

Acknowledges a JetStream message has been received but indicates that the message is not completely processed and should be sent again later, after at least the delay amount.

This is a NOOP for standard NATS messages.

◆ Respond()

void NATS.Client.Msg.Respond ( byte[]  data)

Send a response to the message on the arrival subscription.

Parameters
dataThe response payload to send.
Exceptions
NATSExceptionReply is null or empty.-or-ArrivalSubscription is null.

◆ Term()

virtual void NATS.Client.Msg.Term ( )
virtual

Prevents this message from ever being delivered regardless of maxDeliverCount.

This is a NOOP for standard NATS messages.

◆ ToString()

override string NATS.Client.Msg.ToString ( )

Generates a string representation of the messages.

Returns
A string representation of the messages.

Property Documentation

◆ ConsumeByteCount

long NATS.Client.Msg.ConsumeByteCount
get

The number of bytes the server counts for the message when calculating byte counts. Only applies to JetStream messages received from the server.

Returns
the consumption byte count or -1 if the message implementation does not support this method

◆ Data

byte [] NATS.Client.Msg.Data
getset

Gets or sets the payload of the message.

This copies application data into the message. See AssignData to directly pass the bytes buffer.

See also
AssignData

◆ IsJetStream

virtual bool NATS.Client.Msg.IsJetStream
get

Checks if a message is from Jetstream or is a standard message.

Returns
True if this is a JetStream Message.

◆ LastAck

AckType NATS.Client.Msg.LastAck
get

the last ack that was done with this message, or null if there has not been an ack

Returns
the last ack or null

The documentation for this class was generated from the following file: