pub struct DeadLetterQueue {
pub config: SdkConfig,
pub client: Client,
}Expand description
Client for interacting with AWS SQS dead letter queues.
Provides high-level operations for listing queues, polling messages, and clearing messages from queues.
§Example
use dlq::DeadLetterQueue;
let config = aws_config::from_env().load().await;
let dlq = DeadLetterQueue::from_config(config);
// List all queues
let queues = dlq.list().await;
// Poll messages from a queue
dlq.poll("https://sqs.us-east-1.amazonaws.com/123456789/my-dlq").await;Fields§
§config: SdkConfigThe AWS SDK configuration used for SQS operations
client: ClientThe SQS client instance
Implementations§
Source§impl DeadLetterQueue
impl DeadLetterQueue
Sourcepub async fn send_batch(
&self,
queue_url: &str,
messages: &[impl AsRef<str>],
) -> Result<(), SendError>
pub async fn send_batch( &self, queue_url: &str, messages: &[impl AsRef<str>], ) -> Result<(), SendError>
Sends multiple messages to SQS in a single batch request.
Uses the SQS SendMessageBatch API to efficiently send up to 10 messages
at once. Each message is assigned a unique UUID as its batch entry ID.
§Arguments
queue_url- The URL of the SQS queue to send messages tomessages- A slice of message bodies to send. Each item must implementAsRef<str>.
§Returns
Ok(())- All messages were sent successfullyErr(SendError)- An error occurred during the send operation
§Errors
SendError::BuildEntryFailed- A message entry couldn’t be constructedSendError::AwsSdkError- The SQS API returned an error
§Example
use dlq::DeadLetterQueue;
let config = aws_config::from_env().load().await;
let dlq = DeadLetterQueue::from_config(config);
// Send multiple messages
dlq.send_batch("https://sqs.us-east-1.amazonaws.com/123/my-queue", &["message 1", "message 2", "message 3"]).await?;
// Empty batch is handled gracefully
let empty: Vec<String> = vec![];
dlq.send_batch("https://sqs.us-east-1.amazonaws.com/123/my-queue", &empty).await?;Source§impl DeadLetterQueue
impl DeadLetterQueue
Sourcepub fn from_config(config: SdkConfig) -> Self
pub fn from_config(config: SdkConfig) -> Self
Creates a DeadLetterQueue from a pre-built AWS SDK config.
This is the preferred constructor as it allows the caller to configure
credentials and endpoints based on their needs (e.g., --local flag for LocalStack).
§Arguments
config- Pre-configured AWS SDK configuration
§Example
use dlq::DeadLetterQueue;
let config = aws_config::from_env().load().await;
let dlq = DeadLetterQueue::from_config(config);
// List all queues
let queues = dlq.list().await;Sourcepub async fn _clear(
&self,
url: String,
message_id: String,
receipt_handle: String,
)
pub async fn _clear( &self, url: String, message_id: String, receipt_handle: String, )
Deletes a message from the queue using batch delete.
This is primarily used internally to acknowledge processed messages.
§Arguments
url- The queue URLmessage_id- The SQS message IDreceipt_handle- The receipt handle from when the message was received
Sourcepub async fn list(&self) -> Vec<String>
pub async fn list(&self) -> Vec<String>
Lists all SQS queue URLs in the AWS account.
Handles pagination automatically, returning all queues regardless of count.
§Returns
A vector of queue URL strings.
§Example
use dlq::DeadLetterQueue;
let config = aws_config::from_env().load().await;
let dlq = DeadLetterQueue::from_config(config);
for queue_url in dlq.list().await {
println!("Found queue: {}", queue_url);
}Sourcepub async fn poll(&self, queue_url: &str)
pub async fn poll(&self, queue_url: &str)
Polls messages from a queue and prints them as JSON.
Continuously receives messages until the queue is empty or the maximum number of attempts (10) is reached. Each message is printed to stdout as a JSON object.
§Arguments
queue_url- The URL of the queue to poll messages from
§Example
use dlq::DeadLetterQueue;
let config = aws_config::from_env().load().await;
let dlq = DeadLetterQueue::from_config(config);
// Poll a specific queue
dlq.poll("https://sqs.us-east-1.amazonaws.com/123/my-dlq").await;Trait Implementations§
Source§impl Clone for DeadLetterQueue
impl Clone for DeadLetterQueue
Source§fn clone(&self) -> DeadLetterQueue
fn clone(&self) -> DeadLetterQueue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DeadLetterQueue
impl !RefUnwindSafe for DeadLetterQueue
impl Send for DeadLetterQueue
impl Sync for DeadLetterQueue
impl Unpin for DeadLetterQueue
impl !UnwindSafe for DeadLetterQueue
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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