pub enum NatsMessage {
Core(Box<CoreMessage>),
JetStream(Box<JetStreamMessage>),
}Expand description
A NATS delivery. Two flavours: core NATS (no ack) and JetStream (real ack/nack/redelivery).
Both variants are boxed to keep the enum compact; the wrapped async_nats messages are large.
Variants§
Core(Box<CoreMessage>)
A core NATS subject delivery. Acknowledgement is not supported.
JetStream(Box<JetStreamMessage>)
A JetStream pull-consumer delivery with full ack support.
Trait Implementations§
Source§impl BuildContext<NatsMessage> for JetStreamContext
impl BuildContext<NatsMessage> for JetStreamContext
Source§fn build(msg: &NatsMessage) -> Self
fn build(msg: &NatsMessage) -> Self
msg.Source§impl Debug for NatsMessage
impl Debug for NatsMessage
Source§impl IncomingMessage for NatsMessage
impl IncomingMessage for NatsMessage
Source§fn supports_nack_after(&self) -> bool
fn supports_nack_after(&self) -> bool
Whether this delivery can honor a native delayed redelivery.
true for every JetStream delivery: the protocol carries the delay in the negative
acknowledgement itself, so no opt-in infrastructure is needed. Core NATS has no
acknowledgement at all, so a core delivery reports false and the runtime applies its
broker-agnostic deferred re-publish instead.
Source§async fn nack_after(self, delay: Duration) -> Result<(), AckError>
async fn nack_after(self, delay: Duration) -> Result<(), AckError>
Redelivers this message no sooner than delay, natively: JetStream’s negative
acknowledgement takes the delay as its argument (-NAK {"delay": ns}), so the server holds
the message for that long and then redelivers it on this consumer. Nothing is re-published
and no copy is made, so the delivery count, the stream sequence, and the payload all stay
the ones the message was first delivered with.
§Errors
Returns AckError::Unsupported on a core (non-JetStream) delivery, and
AckError::Broker when the acknowledgement cannot be sent.
Source§async fn ack(self) -> Result<(), AckError>
async fn ack(self) -> Result<(), AckError>
Source§impl Partitioned for NatsMessage
Partitioned lets the workers(N, by_key) runtime feature assign a dispatch lane based on
a well-known message header. NATS has no native partition concept, so the key travels as the
PARTITION_KEY_HEADER header value and the sender is responsible for setting it.
impl Partitioned for NatsMessage
Partitioned lets the workers(N, by_key) runtime feature assign a dispatch lane based on
a well-known message header. NATS has no native partition concept, so the key travels as the
PARTITION_KEY_HEADER header value and the sender is responsible for setting it.
Source§fn partition_key(&self) -> Option<&[u8]>
fn partition_key(&self) -> Option<&[u8]>
None if the broker should pick a partition.