AWS Simple Queue Service (Amazon SQS)学习笔记

Amazon SQS is a fast, reliable, scalable, and fully managed message queuing service. Amazon SQS makes it simple and cost effective to decouple the components of a cloud application.
You can use Amazon SQS to transmit any volume of data, at any level of throughput, without losing messages or requiring other services to be continuously available.

Amazon SQS ensures delivery of each message at least once and supports multiple readers and writers interacting with the same queue.

Message Lifecycle

在这里插入图片描述
Message lifecycle

  1. Component 1 sends Message A to a queue, and the message is redundantly distributed across the Amazon SQS servers.
  2. When Component 2 is ready to process a message, it retrieves messages from the queue,and Message A is returned. While Message A is being processed, it remains in the queue and is not returned to subsequently receive requests for the duration of the visibility timeout.
  3. Component 2 deletes Message A from the queue to prevent the message from being
    received and processed again after the visibility timeout expires.

Delay Queues and Visibility Timeouts

Delay queues allow you to postpone the delivery of new messages in a queue for a specific number of seconds.
Delay queues are similar to visibility timeouts in that both features make messages.
unavailable to consumers for a specific period of time. The difference is that a delay queue hides a message when it is first added to the queue, whereas a visibility timeout hides a message only after that message is retrieved from the queue.

Diagram of visibility timeout
在这里插入图片描述
You can have up to 120,000 messages in flight at any given time.
Amazon SQS supports up to 12 hours’ maximum visibility timeout.

Queue Operations, Unique IDs, and Metadata

Your messages are identified via a globally unique ID that Amazon SQS returns when the message is delivered to the queue.
When you receive a message from the queue, the response includes a receipt handle, which you must provide when deleting the message.

Queue and Message Identifiers

Amazon SQS uses three identifiers that you need to be familiar with: queue URLs, message IDs, and receipt handles.
Amazon SQS assigns each queue an identifier called a queue URL.

Each time you receive a message from a queue, you receive a receipt handle for that message.
The handle is associated with the act of receiving the message, not with the message itself. As stated previously, to delete the message or to change the message visibility, you must provide the receipt handle and not the message ID.

Message Attributes

Message attributes allow you to provide structured metadata items (such as timestamps, geospatial data, signatures, and identifiers) about the message.
Message attributes are optional and separate from, but sent along with, the message body.
Each message can have up to 10 attributes.

Long Polling

the constant calls to ReceiveMessage burn CPU cycles and tie up a thread.
In this situation, you will want to use long polling. With long polling, you send a WaitTimeSeconds argument to ReceiveMessage of up to 20 seconds.

Dead Letter Queues

Amazon SQS provides support for dead letter queues. A dead letter queue is a queue that other (source) queues can target to send messages that for some reason could not be successfully processed. A primary benefit of using a dead letter queue is the ability to sideline and isolate the unsuccessfully processed messages.

Access Control

Amazon SQS Access Control allows you to assign policies to queues that grant specific
interactions to other accounts without that account having to assume IAM roles from your account. These policies are written in the same JSON language as IAM.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值