Skip to main content

LapinMessage

Struct LapinMessage 

Source
pub struct LapinMessage { /* private fields */ }
Expand description

One AMQP delivery, settled with the protocol’s native acknowledgement frames.

Settlement mapping:

  • ack sends basic.ack.
  • nack(true) sends basic.reject with requeue = true; the broker redelivers the message (typically to the same queue, redelivered set).
  • nack(false) sends basic.reject with requeue = false; the broker drops the message, or dead-letters it when the queue has a dead-letter exchange.

Both settle with basic.reject rather than basic.nack. The two frames are the same operation on a single delivery, and they differ in one thing that matters: RabbitMQ 4.3 counts a rejection as a delivery a message has spent and does not count a nack. A handler asking for its message back is a failed attempt, so it is counted, and a quorum queue’s x-delivery-limit can then end a poison loop on the server.

  • nack_after(delay) is native only when the subscription set RabbitQueue::delay; otherwise the default reports the delay unsupported and the runtime uses its broker-agnostic fallback.

Replies received through LapinRequester arrive on a no-ack consumer; settling them is a no-op that always succeeds.

Implementations§

Source§

impl LapinMessage

Source

pub fn exchange(&self) -> &str

The exchange this message was published to (empty for the default exchange).

Source

pub fn routing_key(&self) -> &str

The routing key the message was published with.

Source

pub fn redelivered(&self) -> bool

Whether the broker marked this delivery as redelivered.

Source

pub fn delivery_tag(&self) -> u64

The channel-local delivery tag of this delivery.

Trait Implementations§

Source§

impl BuildContext<LapinMessage> for AmqpContext

Source§

fn build(msg: &LapinMessage) -> Self

Builds the context value by reading fields out of msg.
Source§

impl Debug for LapinMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IncomingMessage for LapinMessage

Source§

async fn ack(self) -> Result<(), AckError>

Acknowledges the delivery with basic.ack.

§Errors

Returns AckError::Broker when the frame cannot be sent, for example because the channel closed after the delivery arrived.

§Cancel safety

Not cancel safe: dropping the future after the frame was queued may still acknowledge the message on the broker.

Source§

async fn nack(self, requeue: bool) -> Result<(), AckError>

Settles negatively with basic.reject: back to the queue under requeue = true, away from it under requeue = false.

The frame is a rejection in both cases, never basic.nack. On one delivery the two are the same operation - basic.nack only adds the multiple flag this crate never sets - but a quorum queue counts a rejected delivery and does not count a nacked one, so a handler’s retry() spends an attempt the server can see and its x-delivery-limit ends the loop.

§Errors

Returns AckError::Broker when the frame cannot be sent, for example because the channel closed after the delivery arrived.

§Cancel safety

Not cancel safe: dropping the future after the frame was queued may still settle the message on the broker.

Source§

fn partition_key(&self) -> Option<&[u8]>

The partition key from the PARTITION_KEY_HEADER, if set. Overridden so keyed worker lanes see it without a Partitioned bound on every dispatch path.

Source§

fn redelivery_count(&self) -> Option<u64>

How many times this message has been delivered, counting this delivery, from the one counter the server keeps: a quorum queue’s x-delivery-count.

A quorum queue counts a delivery that failed - one whose consumer went away without settling it, and one this crate rejected for a handler that asked for the message back.

None where nothing counted: every delivery off a classic queue, which keeps no counter, and the first delivery of any message. A classic queue’s redelivered flag is not a count, and the x-death table a dead-lettered message carries counts the queues it has left rather than the deliveries it has spent, so neither stands in for the server’s own count. That is what leaves the framework’s header in charge of a classic queue’s cap, and it is also what a delayed redelivery through RabbitQueue::delay reports, because the copy the waiting queue releases is a new message the server counts from zero.

Source§

fn supports_nack_after(&self) -> bool

Whether this delivery can honor a native delayed redelivery.

true only when the subscription set RabbitQueue::delay; otherwise the runtime uses its broker-agnostic deferred re-publish.

Source§

async fn nack_after(self, delay: Duration) -> Result<(), AckError>

Redelivers this message no sooner than delay, natively: re-publish it to the delay waiting queue with a per-message TTL, then acknowledge the original. The waiting queue dead-letters the copy back to the origin queue when the TTL fires.

Duplicate-not-loss: the re-publish is sent on the same channel before the original is acked, so a connection failure between them leaves the original unacked (redelivered), not lost. The server drops a copy sent to a waiting queue that does not exist, so a subscription whose broker does not declare topology checks for the waiting queue (or the delayed exchange) when it opens, and refuses to open without it.

§Errors

Returns AckError::Unsupported when the subscription set no delay queue, and AckError::Broker when the re-publish or the ack fails.

§Cancel safety

Not cancel safe: dropping the future may leave the delayed copy published, the original acked, or both.

Source§

fn payload(&self) -> &[u8] ⓘ

Returns the raw payload of the message.
Source§

fn headers(&self) -> &HeaderMap

Returns the headers attached to the message.
Source§

fn decode_error(&self) -> Option<&CodecError>

The error the broker met while reading this delivery, or None when it read the delivery whole. Read more
Source§

impl Partitioned for LapinMessage

Source§

fn partition_key(&self) -> Option<&[u8]>

The partition key from the PARTITION_KEY_HEADER, or None when unset.

Deliveries that share a key are dispatched to the same worker lane under workers(n, by_key); AMQP itself does not interpret the header, so the producer sets it.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T> ⓘ
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T> ⓘ

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T> ⓘ

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PublishedThrough<DefaultSlot> for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more