MessageState

Enum MessageState 

Source
pub enum MessageState {
    Active,
    Deferred,
    Scheduled,
    DeadLettered,
    Completed,
    Abandoned,
}
Expand description

Represents the current state of a message within Azure Service Bus.

This enum maps to Azure Service Bus message states and provides additional states for local message lifecycle management. Each state represents a specific point in the message processing lifecycle with different implications for message availability and processing.

§State Transitions

Messages typically follow these state transitions:

┌─────────────────────────────────────────────────────────────┐
│                    Message Lifecycle                        │
└─────────────────────────────────────────────────────────────┘

          Enqueue
             │
             ▼
         ┌─────────┐     Defer      ┌──────────┐
         │ Active  │ ──────────────► │ Deferred │
         └─────────┘                 └──────────┘
             │                           │
             │ Complete                  │ Activate
             ▼                           ▼
       ┌───────────┐                 ┌─────────┐
       │ Completed │◄────────────────│ Active  │
       └───────────┘                 └─────────┘
             │                           │
             │                           │ Abandon/Retry Limit
             │                           ▼
             │                    ┌─────────────┐
             │                    │ Abandoned / │
             │                    │DeadLettered │
             │                    └─────────────┘
             │
         ┌───────────┐     Schedule     ┌───────────┐
         │ Scheduled │ ◄───────────────│   Active  │
         └───────────┘                 └───────────┘

§Examples

§Checking Message State

use quetty_server::model::MessageState;

let state = MessageState::Active;

match state {
    MessageState::Active => {
        println!("Message is available for immediate processing");
    }
    MessageState::Deferred => {
        println!("Message is deferred - can be activated later");
    }
    MessageState::Scheduled => {
        println!("Message is scheduled for future delivery");
    }
    MessageState::DeadLettered => {
        println!("Message failed processing and is in dead letter queue");
    }
    MessageState::Completed => {
        println!("Message processing completed successfully");
    }
    MessageState::Abandoned => {
        println!("Message processing was abandoned");
    }
}

§State-Based Operations

use quetty_server::model::{MessageModel, MessageState};

fn can_process_message(message: &MessageModel) -> bool {
    matches!(message.state, MessageState::Active | MessageState::Deferred)
}

fn requires_attention(message: &MessageModel) -> bool {
    matches!(message.state, MessageState::DeadLettered | MessageState::Abandoned)
}

fn is_pending_delivery(message: &MessageModel) -> bool {
    matches!(message.state, MessageState::Scheduled)
}

// Usage
let message = get_message();
if can_process_message(&message) {
    println!("Message {} is ready for processing", message.id);
} else if requires_attention(&message) {
    println!("Message {} requires manual intervention", message.id);
}

§UI Display Logic

use quetty_server::model::MessageState;

fn get_state_color(state: &MessageState) -> &'static str {
    match state {
        MessageState::Active => "green",
        MessageState::Deferred => "yellow",
        MessageState::Scheduled => "blue",
        MessageState::DeadLettered => "red",
        MessageState::Completed => "gray",
        MessageState::Abandoned => "orange",
    }
}

fn get_state_description(state: &MessageState) -> &'static str {
    match state {
        MessageState::Active => "Ready for processing",
        MessageState::Deferred => "Deferred for later",
        MessageState::Scheduled => "Scheduled delivery",
        MessageState::DeadLettered => "Failed processing",
        MessageState::Completed => "Processing complete",
        MessageState::Abandoned => "Processing abandoned",
    }
}

§State Descriptions

  • Active - Message is available in the queue for immediate processing
  • Deferred - Message has been deferred and can be retrieved by sequence number
  • Scheduled - Message is scheduled for delivery at a future time
  • DeadLettered - Message exceeded retry limits or failed validation
  • Completed - Message processing completed successfully
  • Abandoned - Message processing was explicitly abandoned

§Default State

The default state is Active, representing a newly enqueued message ready for processing.

Variants§

§

Active

Message is available in the queue for immediate processing. This is the most common state for messages awaiting consumption.

§

Deferred

Message has been deferred by a receiver and can be retrieved later using its sequence number. Deferred messages don’t count toward the queue’s active message count.

§

Scheduled

Message is scheduled for delivery at a specific future time. It will automatically become Active when the scheduled time arrives.

§

DeadLettered

Message has been moved to the dead letter queue due to:

  • Exceeding maximum delivery count
  • Message TTL expiration
  • Explicit dead lettering by receiver
  • Message size limits or other validation failures
§

Completed

Message processing has been completed successfully. This is a terminal state - the message will be removed from the queue.

§

Abandoned

Message processing was abandoned by the receiver. The message may be retried or moved to dead letter queue depending on retry policies.

Trait Implementations§

Source§

impl Clone for MessageState

Source§

fn clone(&self) -> MessageState

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageState

Source§

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

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

impl Default for MessageState

Source§

fn default() -> MessageState

Returns the “default value” for a type. Read more
Source§

impl PartialEq for MessageState

Source§

fn eq(&self, other: &MessageState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MessageState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MessageState

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> SendBound for T
where T: Send,