Struct rabbit_mqr::Queue

source ·
pub struct Queue {
    pub name: String,
    pub channel: Channel,
    pub exchange: String,
    pub routing_key: String,
}
Expand description

Represents a single Queue

Fields§

§name: String§channel: Channel§exchange: String§routing_key: String

Implementations§

source§

impl Queue

source

pub async fn new( name: &str, channel: Channel, options: Option<QueueDeclareOptions>, arguments: Option<FieldTable> ) -> Result<Self, Error>

Construct a Queue

Exchange is: "{name}_exchange"

Routing key is: "{name}_routing_key"


Example Usage:


let channel: Channel = ...;

let queue = Queue::new(
    "my_queue",
    channel,
    None,
    None,
).await?;
source

pub async fn purge(&self, no_wait: bool) -> Result<MessageCount, Error>

Purge the Queue, returns the amount of messages deleted.


Example Usage:


let queue: Queue = ...;

let deleted_count: MessageCount = queue.purge(false).await?;
source

pub async fn recover(&self, requeue: bool) -> Result<(), Error>

Recover the Queue.


Example Usage:


let queue: Queue = ...;

queue.recover(false).await?;
source

pub async fn delete( &self, options: Option<QueueDeleteOptions> ) -> Result<MessageCount, Error>

Delete the Queue, returns the amount of messages deleted.


Example Usage:


let queue: Queue = ...;

let deleted_count: MessageCount = queue.purge(None).await?;
source

pub async fn publish_message( &self, message: Vec<u8>, properties: Option<BasicProperties> ) -> Result<(), Error>

Publish a message to the Queue.


Example Usage:


let queue: Queue = ...;

let message = b"1337".to_vec();

queue.publish_message(message, None).await?;
source

pub async fn get_message(&self) -> Result<Option<GetMessageResult>, Error>

Get a single message from the Queue.

Returns None if there was no messages.


Example Usage:


let queue: Queue = ...;

while let Some(
    GetMessageResult {
       message,
       delivery_tag,
    }
) = queue.get_message.await? {
    ...
}
source

pub async fn acknowledge_message(&self, delivery_tag: u64) -> Result<(), Error>

Acknowledge a gotten message.


Example Usage:


let queue: Queue = ...;

while let Some(
    GetMessageResult {
       message,
       delivery_tag,
    }
) = queue.get_message.await? {
    queue.acknowledge_message(delivery_tag).await?;
}
source

pub async fn no_acknowledge_message( &self, requeue: bool, delivery_tag: u64 ) -> Result<(), Error>

No Acknowledge a gotten message.

Add requeue to true, to requeue the message.


Example Usage:


let queue: Queue = ...;

while let Some(
    GetMessageResult {
       message,
       delivery_tag,
    }
) = queue.get_message.await? {
    ... Some issue processing the message

    queue.no_acknowledge_message(true, delivery_tag).await?;
}

Trait Implementations§

source§

impl Clone for Queue

source§

fn clone(&self) -> Queue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Queue

§

impl !RefUnwindSafe for Queue

§

impl Send for Queue

§

impl Sync for Queue

§

impl Unpin for Queue

§

impl !UnwindSafe for Queue

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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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