pub struct QueueConsumer<T> { /* private fields */ }Expand description
Lapin-backed consumer for JSON messages of type T.
T is the message payload deserialized from each delivery body. The
consumer holds one channel bound to queue_name with the given options.
Implementations§
Source§impl<T> QueueConsumer<T>
impl<T> QueueConsumer<T>
Sourcepub async fn connect(
addr: &str,
queue_name: &str,
options: PublishOptions,
) -> Result<Self>
pub async fn connect( addr: &str, queue_name: &str, options: PublishOptions, ) -> Result<Self>
Connects to the broker, opens a channel, and applies the prefetch count.
Returns an error if the connection, channel, or QoS setup fails.
Sourcepub async fn declare(&self) -> Result<()>
pub async fn declare(&self) -> Result<()>
Declares the durable main queue plus the retry and dead-letter queues when enabled.
The retry queues dead-letters back to the main queue after
retry_interval_ms. Returns an error if any declaration fails.
Sourcepub async fn consume<F, Fut>(&self, handler: F) -> Result<()>
pub async fn consume<F, Fut>(&self, handler: F) -> Result<()>
Consumes deliveries in a loop, acknowledging successes and rerouting failures.
handler receives each decoded message plus its redelivered flag and
returns success or failure. Successful handlers are acknowledged;
handler errors, timeouts, and undecodable bodies go through the
retry/dead-letter policy. F is the handler closure type and Fut its
returned future. Runs until the broker stream ends.
Auto Trait Implementations§
impl<T> Freeze for QueueConsumer<T>where
PhantomData<T>: Freeze,
impl<T> RefUnwindSafe for QueueConsumer<T>where
PhantomData<T>: RefUnwindSafe,
impl<T> Send for QueueConsumer<T>where
PhantomData<T>: Send,
impl<T> Sync for QueueConsumer<T>where
PhantomData<T>: Sync,
impl<T> Unpin for QueueConsumer<T>where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for QueueConsumer<T>where
PhantomData<T>: UnsafeUnpin,
impl<T> UnwindSafe for QueueConsumer<T>where
PhantomData<T>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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