EMAIL SUPPORT

dclessons@dclessons.com

LOCATION

US

SQS and SWS

SQS and SWS

SQS and SWS

Amazon Simple Queue Service

Amazon SQS is a fast, reliable, scalable, and fully managed message queuing service. 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.

An Amazon SQS queue is basically a buffer between the application components that receive data and those components that process the data in your system. Amazon SQS ensures delivery of each message at least once and supports multiple readers and writers interacting with the same queue.

Amazon SQS is engineered to be highly available and to deliver messages reliably and efficiently; however, the service does not guarantee First In, First Out (FIFO) delivery of messages. For many distributed applications, each message can stand on its own and, if all messages are delivered, the order is not important. If your system requires that order be preserved, you can place sequencing information in each message so that you can reorder the messages when they are retrieved from the queue.

Message LifeCycle:

Below figure describes the lifecycle of an Amazon SQS message, called Message A, from creation to deletion. Assume that a queue already exists.

Fig: 8.1

  • Component 1 sends Message A to a queue, and the message is redundantly distributed across the Amazon SQS servers.
  • 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.
  • 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. If you create a delay queue, any message that you send to that queue will be invisible to consumers for the duration of the delay period.

To create a delay queue, use CreateQueue and set the DelaySeconds attribute to any value between 0 and 900 (15 minutes). You can also turn an existing queue into a delay queue by using SetQueueAttributesto set the queue’s DelaySeconds attribute. The default value for DelaySeconds is 0.

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. Figure illustrates the functioning of a visibility timeout.

Fig 8.2

When a message is in the queue but is neither delayed nor in a visibility timeout, it is considered to be “in flight.” 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

The defined operations for Amazon SQS queues are

  • CreateQueue
  • ListQueues
  • DeleteQueue
  • SendMessage
  • SendMessageBatch
  • ReceiveMessage
  • DeleteMessage

Only the AWS account owner or an AWS identity that has been granted the proper permissions can perform operations.

Your messages are identified via a globally unique ID that Amazon SQS returns when the message is delivered to the queue. The ID isn’t required in order to perform any further actions on the message, but it’s useful for tracking whether a particular message in the queue has been received. 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.

When creating a new queue, you must provide a queue name that is unique within the scope of all of your queues. Amazon SQS assigns each queue an identifier called a queue URL, which includes the queue name and other components that Amazon SQS determines. Whenever you want to perform an action on a queue, you must provide its queue URL.

Amazon SQS assigns each message a unique ID that it returns to you in the SendMessage response. This identifier is useful for identifying messages, but note that to delete a message, you need the message’s receipt handle instead of the message ID. The maximum length of a message ID is 100 characters.

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. This means you must always receive a message before you can delete it (that is, you can’t put a message into the queue and then recall it). The maximum length of a receipt handle is 1,024 characters.


Comment

    You are will be the first.

LEAVE A COMMENT

Please login here to comment.