• 沒有找到結果。

Delete your queue

在文檔中 Amazon Simple Queue Service (頁 13-103)

• Next steps (p. 9)

Prerequisites

Before you begin, complete the steps in Setting up Amazon SQS (p. 4).

Step 1: Create a queue

The first and most common Amazon SQS task is creating a queue. This procedure shows how to create and configure a FIFO queue.

1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. Choose Create queue.

3. On the Create queue page, specify the correct region.

4. The Standard queue type is selected by default. Choose FIFO.

You can't change the queue type after you create a queue.

5. Enter a Name for your queue. The name of a FIFO queue must end with the .fifo suffix.

6. To create your queue with the default parameters, scroll to the bottom and choose Create Queue.

Amazon SQS creates the queue and displays the queue's Details page.

Amazon SQS propagates information about the new queue across the system. Because Amazon SQS is a distributed system, you may experience a slight delay before the queue is displayed on the Queues page.

Step 2: Send a message

After you create your queue, you can send a message to it.

1. From the left navigation pane, choose Queues. From the queue list, select the queue that you created.

2. From Actions, choose Send and receive messages.

Step 3: Receive and delete your message

The console displays the Send and receive messages page.

3. Enter text in the Message body

4. Enter a Message group id for the queue. For more information, see FIFO delivery logic (p. 30).

5. (Optional) Enter a Message deduplication id. If you enable content-based deduplication, the message deduplication ID is not required. For more information, see FIFO delivery logic (p. 30).

6. Choose Send message.

Your message is sent and the console displays a success message. Choose View details to display information about the sent message.

Step 3: Receive and delete your message

After you send a message to a queue, you can retrieve the message from the queue. When you request messages from a queue, you can't specify which message to retrieve. Instead, you specify the maximum number of messages (up to 10) that you want to retrieve.

1. From the Queues page, select a queue.

2. From Queue Actions, select Send and receive messages.

The console displays the Send and receive messages page.

3. Choose Poll for messages.

Amazon SQS begins to poll servers to find messages in the queue. The progress bar on the right side of the Receive messages section displays the polling duration.

The Messages section displays a list of the received messages. For each message, the list displays the message ID, sent date, size, and receive count.

4. To delete messages, select the messages that you want to delete and then choose Delete.

5. In the Delete Messages dialog box, choose Delete.

Step 4: Delete your queue

Step 4: Delete your queue

1. From the queue list, select the queue that you have created.

2. From the Queues page, select the queue to delete.

3. Choose Delete queue.

The console displays the Delete queue dialog box.

4. In the Delete queue dialog box, confirm the deletion by entering delete.

5. Choose Delete.

Next steps

Now that you've created a queue and learned how to send, receive, and delete messages and how to delete a queue, you might want to try the following:

• Configure queues, including SSE and other features (p. 10).

• Send a message with attributes. (p. 21)

• Send a message from a VPC. (p. 97)

• Learn more about Amazon SQS workflows and processes: Read How Queues Work (p. 25), Best Practices (p. 57), and Quotas (p. 102). You can also explore the Amazon SQS Articles & Tutorials.

If you ever have any questions, browse the Amazon SQS FAQs or participate in the Amazon SQS Developer Forums.

• Learn how to interact with Amazon SQS programmatically: Read Working with APIs (p. 162) and explore the Sample Code and Libraries and the developer centers:

• Java

• JavaScript

• PHP

• Python

• Ruby

• Windows & .NET

• Learn about keeping an eye on costs and resources in the Automating and troubleshooting Amazon SQS queues (p. 107) section.

• Learn about protecting your data and access to it in the Security (p. 108) section.

Understanding the Amazon SQS console

Configuring Amazon SQS queues (console)

Use the Amazon SQS console to configure and manage Amazon Simple Queue Service (Amazon SQS) queues and features. You can also use the console to configure features such as server-side encryption, associate a dead-letter queue with your queue, or set a trigger to invoke an AWS Lambda function.

Topics

• Understanding the Amazon SQS console (p. 10)

• Creating an Amazon SQS queue (console) (p. 11)

• Editing an Amazon SQS queue (console) (p. 12)

• Configuring queue parameters (console) (p. 13)

• Configuring access policy (console) (p. 14)

• Configuring server-side encryption (SSE) for a queue using SQS-owned encryption keys (console) (p. 14)

• Configuring server-side encryption (SSE) for a queue (console) (p. 15)

• Configuring a dead-letter queue (console) (p. 16)

• Configuring a dead-letter queue redrive (console) (p. 16)

• Configuring cost allocation tags for an Amazon SQS queue (console) (p. 17)

• Subscribing an Amazon SQS queue to an Amazon SNS topic (console) (p. 17)

• Configuring a queue to trigger an AWS Lambda function (console) (p. 18)

Understanding the Amazon SQS console

When you open the console, choose Queues from the navigation pane to display the Queues page. The Queues page provides information about all of your queues in the active region.

The entry for each queue shows the queue type and other information about the queue. The Type column helps you distinguish standard queues from First-In-First Out (FIFO) queues at a glance.

From the Queues page, there are two ways to perform actions on a queue. You can choose the option next to the queue name and then choose the action you want to perform on the queue.

Creating a queue

You can also choose the queue name, which open the Details page for the queue. The Details page includes the same actions as the Queues page. In addition, you can choose one of the tabs below the Details section to view additional configuration details and actions.

Creating an Amazon SQS queue (console)

You can use the Amazon SQS console to create standard queues (p. 27) and FIFO queues (p. 28).

The console provides default values for all settings except for the queue name.

Important

Do not add personally identifiable information (PII) or other confidential or sensitive information in queue names. Queue names are accessible to many Amazon Web Services, including billing and CloudWatch logs. Queue names are not intended to be used for private or sensitive data.

To create an Amazon SQS queue (console)

1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. Choose Create queue.

3. For Type, the Standard queue type is set by default. To create a FIFO queue, choose FIFO.

NoteYou can't change the queue type after you create the queue.

4. Enter a Name for your queue. The name of a FIFO queue must end with the .fifo suffix.

5. (Optional) The console sets default values for the queue configuration parameters (p. 13). Under Configuration, you can set new values for the following parameters:

a. For Visibility timeout , enter the duration and units. The range is from 0 seconds to 12 hours.

The default value is 30 seconds.

b. For Message retention period, enter the duration and units. The range is from 1 minute to 14 days. The default value is 4 days.

Editing a queue

c. For Delivery delay, enter the duration and units. The range is from 0 seconds to 15 minutes.

The default value is 0 seconds.

d. For Maximum message size, enter a value. The range is from 1 KB to 256 KB. The default value is 256 KB.

e. For Receive message wait time, enter a value. The range is from 0 to 20 seconds. The default value is 0 seconds, which sets short polling (p. 43). Any non-zero value sets long polling.

f. For a FIFO queue, choose Enable content-based deduplication to enable content-based deduplication. The default setting is disabled.

g. (Optional) For a FIFO queue, to enable higher throughput for sending and receiving messages in the queue, choose Enable high throughput FIFO.

Choosing this option changes the related options (Deduplication scope and FIFO throughput limit) to the required settings for enabling high throughput for FIFO queues. If you change any of the settings required for using high throughput FIFO, normal throughput is in effect for the queue, and deduplication occurs as specified. For more information, see High throughput for FIFO queues (p. 32) and Quotas related to messages (p. 103).

h. For Redrive allow policy, choose Allow all (the default), By queue or Deny all. When choosing By queue, specify a list of up to 10 source queues by the Amazon Resource Name (ARN).

6. (Optional) Define an Access policy. The access policy (p. 139) defines the accounts, users, and roles that can access the queue. The access policy also defines the actions (such as SendMessage, ReceiveMessage, or DeleteMessage) that the users can access. The default policy allows only the queue owner to send and receive messages.

To define the access policy, do one of the following:

• Choose Basic to configure who can send messages to the queue and who can receive messages from the queue. The console creates the policy based on your choices and displays the resulting access policy in the read-only JSON panel.

• Choose Advanced to modify the JSON access policy directly. This allows you to specify a custom set of actions that each principal (account, user, or role) can perform.

7. (Optional) To configure encryption (p. 15) for the queue, expand Encryption.

8. (Optional) To configure a dead-letter queue (p. 16) to receive undeliverable messages, expand Dead-letter queue.

9. (Optional) To add tags (p. 17) to the queue, expand Tags.

10. Choose Create queue. Amazon SQS creates the queue and displays the queue's Details page.

Amazon SQS propagates information about the new queue across the system. Because Amazon SQS is a distributed system, you might experience a slight delay before the console displays the queue on the Queues page.

After creating a queue, you can send messages (p. 20) to it, and receive and delete

messages (p. 22). You can also edit (p. 12) any of the queue configuration settings except the queue type.

Editing an Amazon SQS queue (console)

You can use the Amazon SQS console to edit any queue configuration parameters (except the queue type) and add or remove queue features.

To edit an Amazon SQS queue (console)

1. Open the Queues page of the Amazon SQS console.

Configuring queue parameters

2. Select a queue, and then choose Edit.

3. (Optional) Under Configuration, update the queue's configuration parameters (p. 13).

4. (Optional) To update the access policy (p. 14), under Access policy, modify the JSON policy.

5. (Optional) To add, update, or remove encryption (p. 15), expand Encryption.

6. (Optional) To add, update, or remove a dead-letter queue (p. 16) (which allows you to receive undeliverable messages), expand Dead-letter queue.

7. (Optional) To add, update, or remove the tags (p. 17) for the queue, expand Tags.

8. Choose Save.

The console displays the Details page for the queue.

Configuring queue parameters (console)

When you create (p. 11) or edit (p. 12) a queue, you can configure the following parameters:

Visibility timeout – The length of time that a message received from a queue (by one consumer) won't be visible to the other message consumers. For more information, see Visibility timeout (p. 49).

Note

Using the console to configure the visibility timeout configures the timeout value for all of the messages in the queue. To configure the timeout for single or multiple messages, you must use one of the AWS SDKs.

Message retention period – The amount of time that Amazon SQS retains messages that remain in the queue. By default, the queue retains messages for four days. You can configure a queue to retain messages for up to 14 days. For more information, see Message retention period.

Delivery delay – The amount of time that Amazon SQS will delay before delivering a message that is added to the queue. For more information, see Delivery delay (p. 51).

Maximum message size – The maximum message size for this queue. For more information, see Maximum message size (p. 69).

Receive message wait time – The maximum amount of time that Amazon SQS waits for messages to become available after the queue gets a receive request. For more information, see Amazon SQS short and long polling (p. 43).

Enable content-based deduplication – Amazon SQS can automatically create deduplication IDs based on the body of the message. For more information, see Amazon SQS FIFO (First-In-First-Out) queues (p. 28).

Enable high throughput FIFO – Use to enable high throughput for messages in the queue. Choosing this option changes the related options (Deduplication scope and FIFO throughput limit) to the required settings for enabling high throughput for FIFO queues. For more information, see High throughput for FIFO queues (p. 32) and Quotas related to messages (p. 103).

Redrive allow policy: defines which source queues can use this queue as the dead-letter queue. For more information, see Amazon SQS dead-letter queues (p. 45).

To configure queue parameters for an existing queue (console) 1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. In the navigation pane, choose Queues. Choose a queue and choose Edit.

3. Scroll to the Configuration section.

4. For Visibility timeout , enter the duration and units. The range is 0 seconds to 12 hours. The default value is 30 seconds.

5. For Message retention period, enter the duration and units. The range is 1 minute to 14 days. The default value is 4 days.

Configuring access policy

6. For Delivery delay, enter the duration and units. The range is 0 seconds to 15 minutes. The default value is 0 seconds.

7. For Maximum message size, enter a value. The range is 1 KB to 256 KB. The default value is 256 KB.

8. For a standard queue, enter a value for Receive message wait time. The range is 0 to 20 seconds.

The default value is 0 seconds, which sets short polling (p. 43). Any non-zero value sets long polling.

9. For a FIFO queue, choose Enable content-based deduplication to enable content-based deduplication. The default setting is disabled.

10. (Optional) For a FIFO queue, to enable higher throughput for sending and receiving messages in the queue, choose Enable high throughput FIFO.

Choosing this option changes the related options (Deduplication scope and FIFO throughput limit) to the required settings for enabling high throughput for FIFO queues. If you change any of the settings required for using high throughput FIFO, normal throughput is in effect for the queue, and deduplication occurs as specified. For more information, see High throughput for FIFO queues (p. 32) and Quotas related to messages (p. 103).

11. For Redrive allow policy, choose Allow all (the default), By queue or Deny all. When choosing By queue, specify a list of up to 10 source queues by the Amazon Resource Name (ARN).

12. When you finish configuring the queue parameters, choose Save.

Configuring access policy (console)

When you edit (p. 12) a queue, you can configure its access policy.

The access policy defines the accounts, users, and roles that can access the queue. The access policy also defines the actions (such as SendMessage, ReceiveMessage, or DeleteMessage) that the users can access. The default policy allows only the queue owner to send and receive messages.

To configure the access policy for an existing queue (console)

1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. In the navigation pane, choose Queues.

3. Choose a queue and choose Edit.

4. Scroll to the Access policy section.

5. Edit the access policy statements in the input box.

6. When you finish configuring the access policy, choose Save.

Configuring server-side encryption (SSE) for a

queue using SQS-owned encryption keys (console)

Amazon SQS managed SSE (SSE-SQS) is managed server-side encryption that uses SQS-owned encryption keys to protect sensitive data sent over message queues. With SSE-SQS, you don't need to create and manage encryption keys, or modify your code to encrypt your data. SSE-SQS lets you transmit data securely and helps you meet strict encryption compliance and regulatory requirements at no additional cost.

SSE-SQS protects data at rest using 256-bit Advanced Encryption Standard (AES-256) encryption. SSE encrypts messages as soon as Amazon SQS receives them. Amazon SQS stores messages in encrypted form and decrypts them only when sending them to an authorized consumer.

Configuring SSE-KMS for a queue

To configure SSE-SQS encryption for a queue (console)

1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. In the navigation pane, choose Queues.

3. Choose a queue, and then choose Edit.

4. Expand Encryption.

5. For Server-side encryption, choose Enabled.

6. Select Amazon SQS key (SSE-SQS). There is no additional fee for using this option.

7. Choose Save.

Configuring server-side encryption (SSE) for a queue (console)

To protect the data in a queue's messages, you can enable server-side encryption (SSE) for a queue.

Amazon SQS integrates with the Amazon Web Services Key Management Service (Amazon Web Services KMS) to manage KMS keys for server-side encryption (SSE). For information about using SSE, see Encryption at rest (p. 109).

The KMS key that you assign to your queue must have a key policy that includes permissions for all principals that are authorized to use the queue. For information, see Key Management (p. 111).

If you aren't the owner of the KMS key, or if you log in with an account that doesn't have

kms:ListAliases and kms:DescribeKey permissions, you won't be able to view information about the KMS key on the Amazon SQS console. Ask the owner of the KMS key to grant you these permissions.

For more information, see Key Management (p. 111).

When you create (p. 11) or edit (p. 12) a queue, you can configure SSE-KMS.

To configure SSE-KMS for an existing queue (console)

1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. In the navigation pane, choose Queues.

3. Choose a queue, and then choose Edit.

4. Expand Encryption.

5. For Server-side encryption, choose Enabled.

6. Select AWS Key Management Service key (SSE-KMS).

The console displays the Description, the Account, and the KMS key ARN of the KMS key.

7. Specify the KMS key ID for the queue. For more information, see Key terms (p. 110).

a. Choose the Choose a KMS key alias option.

b. The default key is the Amazon Web Services managed KMS key for Amazon SQS. To use this key, choose it from the KMS key list.

c. To use a custom KMS key from your Amazon Web Services account, choose it from the KMS key list. For instructions on creating custom KMS keys, see Creating Keys in the Amazon Web Services Key Management Service Developer Guide.

d. To use a custom KMS key that is not in the list, or a custom KMS key from another Amazon Web Services account, choose Enter the KMS key alias and enter the KMS key Amazon Resource Name (ARN).

8. (Optional) For Data key reuse period, specify a value between 1 minute and 24 hours. The default is 5 minutes. For more information, see Understanding the data key reuse period (p. 114).

Configuring a dead-letter queue

9. When you finish configuring SSE-KMS, choose Save.

Configuring a dead-letter queue (console)

A dead-letter queue is a queue that one or more source queues can use for messages that are not consumed successfully. For more information, see Amazon SQS dead-letter queues (p. 45).

Amazon SQS does not create the dead-letter queue automatically. You must first create the queue before using it as a dead-letter queue..

The dead-letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead-letter queue of a standard queue must also be a standard queue.

When you create (p. 11) or edit (p. 12) a queue, you can configure a dead-letter queue.

To configure a dead-letter queue for an existing queue (console) 1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

2. In the navigation pane, choose Queues.

3. Choose a queue and choose Edit.

4. Scroll to the Dead-letter queue section and choose Enabled.

5. Choose the Amazon Resource Name (ARN) of an existing Dead Letter Queue that you want to associate with this source queue.

6. To configure the number of times that a message can be received before being sent to a dead-letter queue, set Maximum receives to a value between 1 and 1,000.

7. When you finish configuring the dead-letter queue, choose Save.

After you save the queue, the console displays the Details page for your queue. On the Details page, the Dead-letter queue tab displays the Maximum Receives and Dead Letter Queue ARN in the

After you save the queue, the console displays the Details page for your queue. On the Details page, the Dead-letter queue tab displays the Maximum Receives and Dead Letter Queue ARN in the

在文檔中 Amazon Simple Queue Service (頁 13-103)

相關文件