Skip to main content

AzureSessionProvider

Struct AzureSessionProvider 

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

Azure Service Bus session provider for ordered message processing.

Implements the SessionProvider trait using the Azure Service Bus REST API, providing exclusive session-locked access to messages within a single session. All messages within a session are delivered in strict FIFO order.

§Session Lifecycle

  1. Obtain via AzureServiceBusProvider::create_session_client.
  2. Call receive_message to fetch the next message.
  3. Process the message, then call complete_message or abandon_message.
  4. Call renew_session_lock periodically for long-running processing to prevent session lock expiry.
  5. Call close_session when finished.

Implementations§

Source§

impl AzureSessionProvider

Source

pub fn new( session_id: SessionId, queue_name: QueueName, session_timeout: Duration, http_client: HttpClient, namespace_url: String, config: AzureServiceBusConfig, credential: Option<Arc<dyn TokenCredential + Send + Sync>>, ) -> Self

Create a new session provider.

Normally obtained through AzureServiceBusProvider::create_session_client rather than constructed directly.

§Arguments
  • session_id - The session to operate on.
  • queue_name - The queue containing the session.
  • session_timeout - How long the session lock is expected to be held; used to compute session_expires_at and refreshed on each receive and lock renewal.
  • http_client - Shared HTTP client (cloned from the parent provider).
  • namespace_url - Base URL of the Service Bus namespace.
  • config - Provider configuration (used for SAS token generation).
  • credential - Optional token credential for AAD-based auth.

Trait Implementations§

Source§

impl Debug for AzureSessionProvider

Source§

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

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

impl SessionProvider for AzureSessionProvider

Source§

fn receive_message<'life0, 'async_trait>( &'life0 self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<ReceivedMessage>, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receive the next message from the session using PeekLock mode.

Calls DELETE {namespace}/{queue}/sessions/{sessionId}/messages/head?timeout={t}. On success the session lock expiry is refreshed and the message lock token is stored internally so that complete_message, abandon_message, and dead_letter_message can resolve the token by receipt handle.

§Errors
  • QueueError::SessionNotFound – the session no longer exists or the lock expired.
  • QueueError::ProviderError – network or broker error.
Source§

fn complete_message<'life0, 'life1, 'async_trait>( &'life0 self, receipt: &'life1 ReceiptHandle, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Complete (delete) a session message using its lock token.

Calls DELETE {namespace}/{queue}/sessions/{sessionId}/messages/{lockToken}.

§Errors
  • QueueError::InvalidReceipt – receipt not found locally or lock expired on broker.
Source§

fn abandon_message<'life0, 'life1, 'async_trait>( &'life0 self, receipt: &'life1 ReceiptHandle, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Abandon a session message and make it available for re-delivery.

Calls PUT {namespace}/{queue}/sessions/{sessionId}/messages/{lockToken}.

§Errors
  • QueueError::InvalidReceipt – receipt not found locally or lock expired.
Source§

fn dead_letter_message<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, receipt: &'life1 ReceiptHandle, reason: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Dead-letter a session message.

Calls POST {namespace}/{queue}/sessions/{sessionId}/messages/{lockToken}/$deadletter with a JSON body containing DeadLetterReason.

§Errors
  • QueueError::InvalidReceipt – receipt not found locally or lock expired.
Source§

fn renew_session_lock<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Renew the session lock to extend the exclusive hold on the session.

Calls POST {namespace}/{queue}/sessions/{sessionId}/renewlock. On success the local session_expires_at is refreshed.

§Errors
  • QueueError::SessionNotFound – the session lock has already expired.
Source§

fn close_session<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Release local session state.

Clears all locally cached message lock tokens. The Azure Service Bus REST API has no endpoint to release a session lock before it expires; the broker releases the lock automatically after the session timeout configured on the queue entity (typically 30 s – 5 min). For workloads that need immediate hand-off, configure a shorter session lock duration on the queue entity or use the AMQP-based SDK which supports explicit session release.

Source§

fn session_id(&self) -> &SessionId

Get session ID
Source§

fn session_expires_at(&self) -> Timestamp

Get session expiry time

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>

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