Interface INatsJSMsg<T>
This interface provides an optional contract when passing messages to processing methods which is usually helpful in creating test doubles in unit testing.
public interface INatsJSMsg<out T>Type Parameters
- T
- Data type of the payload 
Remarks
Using this interface is optional and should not affect functionality.
There is a performance penalty when using this interface because NatsJSMsg<T> is a value type and boxing is required. A boxing allocation occurs when a value type is converted to the interface type. This is because the interface type is a reference type and the value type must be converted to a reference type. You should benchmark your application to determine if the interface is worth the performance penalty or makes any noticeable degradation in performance.
Properties
- Connection
- The connection messages was delivered on. 
- Data
- Deserialized user data. 
- Error
- Any errors (generally serialization errors) encountered while processing the message. 
- Headers
- Headers of the user message if set. 
- Metadata
- Additional metadata about the message. 
- ReplyTo
- The reply subject that subscribers can use to send a response back to the publisher/requester. 
- Size
- Message size in bytes. 
- Subject
- Subject of the user message. 
Methods
- AckAsync(AckOpts?, CancellationToken)
- Acknowledges the message was completely handled. 
- AckProgressAsync(AckOpts?, CancellationToken)
- Indicates that work is ongoing and the wait period should be extended. 
- AckTerminateAsync(AckOpts?, CancellationToken)
- Instructs the server to stop redelivery of the message without acknowledging it as successfully processed. 
- EnsureSuccess()
- Throws an exception if the message contains any errors (generally serialization errors). 
- NakAsync(AckOpts?, TimeSpan, CancellationToken)
- Signals that the message will not be processed now and processing can move onto the next message. 
- ReplyAsync(NatsHeaders?, string?, NatsPubOpts?, CancellationToken)
- Reply with an empty message.