zoukankan      html  css  js  c++  java
  • [AWS] SQS

    Amazon SQS is a service that hosts the queue of messages (requests and responses) from the decoupled application components. Have a quick look at this SQS workflow to understand it better.

    Let's see how to create an SQS queue, and learn to send/receive messages.

    A. Queues Dashboard

    From the AWS management console, select SQS (Simple Queue Service), or you can directly go to the Queues dashboard. Start the Create queue wizard from there.

    Launch Create queue from Amazon SQS homepage

    Launch Create queue from Queues dashboard

    B. Create a Queue

    A queue can be created quickly in three steps:

    1. General details - Provide a case-sensitive name, and choose the type of queue - Standard or FIFO, you want to create. A standard queue supports an unlimited number of transactions per second (TPS) for each API action (SendMessage, ReceiveMessage, or DeleteMessage). Whereas, FIFO queues support up to 3000 messages per second while strictly preserving the message order.

    Snapshot: Create queue - General details

    1. Configuration details - You can set the following items:

      • Visibility timeout - The time-duration (0 seconds - 12 hours) after which a consumer message can become visible to the other consumers. Generally, the consumer must process and delete a message from the queue.

      • Message retention period - The duration (1 minute - 14 days) for which the queue retains a message that does not get deleted. Amazon SQS will automatically delete messages that have been in a queue for more than the specified period.

      • Delivery delay - The time (0 seconds - 15 minutes) to intentionally delay the delivery of each (new) message added to the queue. According to AWS:

        If your consumers need additional time to process messages, you must delay each new message coming to the queue.

      • Maximum message size - It should be between 1 KB and 256 KB.

    Snapshot: Create queue - Configuration details

    1. Access policy - You can define specifically who can send/receive messages to/from your queue. Choose the queue owner, or specified AWS accounts, IAM users, and roles as sender/receiver. The access policy can also be defined in JSON format.

    Snapshot: Create queue - Access policy

    C. Details of an Existing Queue

    Select a queue from the Queues dashboard to view the basic details and configuration.

    Snapshot: Details of an existing queue

    In the snapshot above, the URL https://sqs.us-east-2.amazonaws.com/014421265158/MyQueue is an essential field to use in your application components. In addition, you can also view details about the Lambda triggers, and the access policy. You can even monitor various metrics, such as approximate age of message, the number of messages sent/received/delayed/deleted/empty receives, and size consumed by sent messages.

    D. Send and receive messages

    For the selected queue, you can either send/receive messages or configure Lambda function trigger. Let's see how to send and receive messages using a Standard queue.

    1. Send message
      Specify the message body and delay duration while sending a message. As stated earlier, you must add a delay to each new message, if your consumers need additional time to process messages. In other words, your consumer will receive the message only after the duration specified here.

      You can also mention the metadata, such as timestamps, geospatial data, signatures, and identifiers in the form of Message attributes.

      In a FIFO queue, there is an additional concept of message group, to ensures that the messages belonging to a particular group are processed in a strict order.

    Snapshot: Message body and delay duration while sending a message

    1. Receive messages
      A consumer cannot choose a specific message to receive. Instead, a consumer polls to receive up to 10 number of messages from the queue. The snapshot below shows a message received after polling. The default polling duration is set to 30 seconds.

      Next, click on the message ID to view the message details, body, and metadata. Later, delete the message manually, if not in use.

    Snapshot: Poll for messages to receive messages

    Snapshot: View the message details, body, and metadata.

    Note: SQS pricing is based on the count and size of messages, and the interactions with Amazon S3 and the AWS Key Management Service.

    External Resource

    1. Basic Amazon SQS architecture
    2. Refer to the Getting started with Amazon SQS, that demonstrates the following steps:
      • Step 1: Create a queue
      • Step 2: Send a message
      • Step 3: Receive and delete your message
      • Step 4: Delete your queue
  • 相关阅读:
    闲话: 恭喜园子里的MVP一下, 同时问所有奋斗在技术领域的兄弟过节好~
    随便说两句: 表设计兼一些设计分析的讨论
    是他妈傻子写的么?
    Utility Wish List
    我终于有个偶像了
    也论标准: 统一是啥好事情?
    linux 编程学习笔记(1)搭建c(c++)开发环境
    Immutable Collections(2)ImmutableList<T>实现原理.(上)
    托管代码的进程注入&CLR宿主
    .NET安全揭秘系列博文索引
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14552082.html
Copyright © 2011-2022 走看看