1. 程式人生 > >Using Amazon SQS Dead-Letter Queues to Control Message Failure

Using Amazon SQS Dead-Letter Queues to Control Message Failure


Michael G. Khmelnitsky, Senior Programmer Writer

Sometimes, messages can’t be processed because of a variety of possible issues, such as erroneous conditions within the producer or consumer application. For example, if a user places an order within a certain number of minutes of creating an account, the producer might pass a message with an empty string instead of a customer identifier. Occasionally, producers and consumers might fail to interpret aspects of the protocol that they use to communicate, causing message corruption or loss. Also, the consumer’s hardware errors might corrupt message payload. For these reasons, messages that can’t be processed in a timely manner are delivered to a dead-letter message queue

.

The recent post Building Scalable Applications and Microservices: Adding Messaging to Your Toolbox gives an overview of messaging in the microservice architecture of modern applications. This post explains how and when you should use dead-letter queues to gain better control over message handling in your applications. It also offers some resources for configuring a dead-letter

message queue in Amazon Simple Queue Service (SQS).

What are the benefits of dead-letter queues?

The main task of a dead-letter queue is handling message failure. A dead-letter queue lets you set aside and isolate messages that can’t be processed correctly to determine why their processing didn’t succeed. Setting up a dead-letter queue allows you to do the following:

  • Configure an alarm for any messages delivered to a dead-letter queue.
  • Examine logs for exceptions that might have caused messages to be delivered to a dead-letter queue.
  • Analyze the contents of messages delivered to a dead-letter queue to diagnose software or the producer’s or consumer’s hardware issues.
  • Determine whether you have given your consumer sufficient time to process messages.

How do high-throughput, unordered queues handle message failure?

High-throughput, unordered queues (sometimes called standard or storage queues) keep processing messages until the expiration of the retention period. This helps ensure continuous processing of messages, which minimizes the chances of your queue being blocked by messages that can’t be processed. It also ensures fast recovery for your queue.

In a system that processes thousands of messages, having a large number of messages that the consumer repeatedly fails to acknowledge and delete might increase costs and place extra load on the hardware. Instead of trying to process failing messages until they expire, it is better to move them to a dead-letter queue after a few processing attempts.

Note: This queue type often allows a high number of in-flight messages. If the majority of your messages can’t be consumed and aren’t sent to a dead-letter queue, your rate of processing valid messages can slow down. Thus, to maintain the efficiency of your queue, you must ensure that your application handles message processing correctly.

How do FIFO queues handle message failure?

FIFO (first-in-first-out) queues (sometimes called service bus queues) help ensure exactly-once processing by consuming messages in sequence from a message group. Thus, although the consumer can continue to retrieve ordered messages from another message group, the first message group remains unavailable until the message blocking the queue is processed successfully.

Note: This queue type often allows a lower number of in-flight messages. Thus, to help ensure that your FIFO queue doesn’t get blocked by a message, you must ensure that your application handles message processing correctly.

When should I use a dead-letter queue?

  • Do use dead-letter queues with high-throughput, unordered queues. You should always take advantage of dead-letter queues when your applications don’t depend on ordering. Dead-letter queues can help you troubleshoot incorrect message transmission operations. Note: Even when you use dead-letter queues, you should continue to monitor your queues and retry sending messages that fail for transient reasons.
  • Do use dead-letter queues to decrease the number of messages and to reduce the possibility of exposing your system to poison-pill messages (messages that can be received but can’t be processed).
  • Don’t use a dead-letter queue with high-throughput, unordered queues when you want to be able to keep retrying the transmission of a message indefinitely. For example, don’t use a dead-letter queue if your program must wait for a dependent process to become active or available.
  • Don’t use a dead-letter queue with a FIFO queue if you don’t want to break the exact order of messages or operations. For example, don’t use a dead-letter queue with instructions in an Edit Decision List (EDL) for a video editing suite, where changing the order of edits changes the context of subsequent edits.

How do I get started with dead-letter queues in Amazon SQS?

Amazon SQS is a fully managed service that offers reliable, highly scalable hosted queues for exchanging messages between applications or microservices. Amazon SQS moves data between distributed application components and helps you decouple these components. It supports both standard queues and FIFO queues. To configure a queue as a dead-letter queue, you can use the AWS Management Console or the Amazon SQS SetQueueAttributes API action.

To get started with dead-letter queues in Amazon SQS, see the following topics in the Amazon SQS Developer Guide:

To start working with dead-letter queues programmatically, see the following resources:

相關推薦

Using Amazon SQS Dead-Letter Queues to Control Message Failure

Michael G. Khmelnitsky, Senior Programmer Writer Sometimes, messages can’t be processed because of a variety of possible issues,

Using Amazon SQS Dead Letter Queues

After Jason Fulghum recently posted a blog entry about using Amazon SQS dead letter queues with the AWS SDK for Java, I thought his post would be

Robust Serverless Application Design with AWS Lambda Dead Letter Queues

Gene Ting, Solutions Architect AWS Lambda is a serverless, event-driven compute service that allows developers to bring their functions t

利用樹莓派漏極輸出控制電機 Using Raspberry Pi open drain output GPIO to control a moter

Keyword關鍵字 Raspberry Pi樹莓派, GPIO 通用IO, open drain output漏極輸出 Motivation動機 專案中有一個pwm控制的電機,需要漏極開路[8]( An open collector i

Using Amazon EFS to Persist Data from Amazon ECS Containers

My colleagues Jeremy Cowan and Drew Dennis sent a nice guest post that shows how to use Amazon Elastic File System with Amazon ECS. —

Maven install [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources

all div pro 警告 enc resource encoding sin 配置 一、背景   maven項目install過程中,出現:[WARNING] Using platform encoding (UTF-8 actually) to copy filter

ERROR:Unable to control A20 line!XMS Driver not installed

網刻 ghost 報錯使用誠龍網維或是其他網克軟件通過PXE網絡啟動或是U盤啟動進入GHOST時提示如下錯誤信息:ERROR:Unable to control A20 line!XMS Driver not installed. Warning:the high memory area (HMA) is n

誠龍網維ERROR:Unable to control A20 line!XMS Driver not insta

網刻 ghost 報錯 誠龍網維使用誠龍網維或是其他網克軟件通過PXE網絡啟動或是U盤啟動進入GHOST時提示如下錯誤信息:ERROR:Unable to control A20 line!XMS Driver not installed. Warning:the high memory area (HMA)

測試錯誤ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.問題的解決

sin ces level initial prope 系統 找到 default The ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging

RabbitMQ Dead Letter Exchange

簡稱DLX 如果一個queue設定了DLX,那麼在rabbitmq的管理控制檯中的這個queue上就會多個標誌,如圖: 邊上還有DLK,是dead-letter-routing-key的縮寫。 佇列中的訊息,有可能是'dead-lettered',字面意思就是'死信',當下面的這些情況發生時,信就被認為是‘

Analyze and visualize your VPC network traffic using Amazon Kinesis and Amazon Athena

Network log analysis is a common practice in many organizations.  By capturing and analyzing network logs, you can learn how devices on your netwo

How Annalect built an event log data analytics solution using Amazon Redshift

Ingesting and analyzing event log data into a data warehouse in near real-time is challenging. Data ingest must be fast and efficient. The data wa

Amazon built an AI tool to hire people but had to shut it down because it was discriminating against women

Amazon worked on building an artificial-intelligence tool to help with hiring, but the plans backfired when the company discovered the system discriminated

Amazon and SiriusXM team up to offer free service and Echo Dots

Amazon and SiriumXM have partnered up to bring together streaming radio and the Amazon Echo. Echo owners can enjoy a three-month trial of SiriusXM for free

Training models with unequal economic error costs using Amazon SageMaker

Many companies are turning to machine learning (ML) to improve customer and business outcomes. They use the power of ML models built over “big dat

Discovering and indexing podcast episodes using Amazon Transcribe and Amazon Comprehend 

As an avid podcast listener, I had always wished for an easy way to glimpse at the transcript of an episode to decide whether I should add it to m

Want to control something with Siri? Here’s how.

1) Firstly, download the scripts from here.2) Then, open up siricontrol.py and add your username and password of your new Gmail account. This should be sel

Gee, Male: Using My Inbox As a Window To Gender Bias

Gee, Male: Using My Inbox As a Window To Gender BiasIf you can’t see it, you can’t be it. That’s why role models and representation is so important in chan

Using Amazon’s Mechanical Turk for Machine Learning Data

How to build a model from Mechanical Turk resultsAmazon Mechanical Turk will notify you when your results are ready and you will finally have a labelled da

New Engen improves customer acquisition marketing campaigns using Amazon Rekognition

New Engen is a cross-channel performance marketing technology company that uses its proprietary software products and creative solutions to help t