SQS is the simple queue service, which is a distributed Message Queue Service. It is very simple to use. The Message Queue Service can be used for buffer burst, so that the entire service can be processed asynchronously and components are not always available.
When using Amazon SQS, developers only need to use five APIs:
Createqueue, sendmessage, receivemessage, changemessagevisibility, and deletemessage.
Amazon SQS tries its best to keep the message order. However, due to the distributed nature of the queue, SQS cannot guarantee the order in which messages are sent.Each Amazon SQS queue has configurable visibility timeout (default visibility timeout ). The message remains invisible to other readers within the specified time after it is read from the queue. As long as the message processing time is shorter than the visibility timeout, each message is processed and deleted. If the component that processes the message fails or is unavailable, the message is visible to any component that reads the queue after the visibility timeout. This allows you to allow multiple components to read messages from the same queue at the same time. Each component is responsible for processing different messages.
After Amazon SQS returns a message, the message is saved in the queue, called in flight. Delete the request to confirm that the message has been processed. If the message is not deleted, Amazon SQS delivers the message in another receiving request. Because a server in the distributed Amazon SQS system is unavailable for deletion, the deletemessage operation fails to delete all copies of the message. The message copy may be delivered again. Therefore, the corresponding design should be carried out in the application so that no error or inconsistency will occur when the deleted message is received again.
If no request is issued for a queue for more than 30 consecutive days, SQS may delete the queue: sendmessage, receivemessage, deletemessage, getqueueattributes, and setqueueattributes. This should be taken into account when designing an application, which is disgusting and should not be of this nature.
Short Round Robin and long round robin (the difference is whether sampling is performed)
If Short Round Robin is used, when you retrieve messages from the queue, Amazon SQS samples a subset of the server (based on weighted random distribution) and returns messages only from these servers. This means that the specified receiving request may not return all your messages. Alternatively, if your queue contains a small number of messages (less than 1 000 messages), it means that the specific request may not return any of your messages, and subsequent requests will return any of your messages. If you continue to retrieve messages from your queue, Amazon SQS samples all servers and receives all your messages.
One advantage of using Amazon SQS for long polling is that when no message can be returned to reply to the receivemessage request sent to the Amazon SQS queue, the number of empty responses can be reduced. Before sending a response, long polling allows the Amazon SQS product to wait until messages in the queue are available. Therefore, if the connection does not time out, the response to the receivemessage request will contain at least one available message (if any) and can contain at most the maximum number of messages requested in the receivemessage call.
Receive message wait time indicates whether to set short polling or long polling. 0 indicates short polling, up to 20.
Amazon SQS uses the following three identifiers you need to be familiar:
Queue URL
Message ID
Receiving handle
The maximum number of message in flight messages in each queue is 120,000. The message is in flight status after it is received by the queue, but has not been deleted from the queue. If you reach the 120,000 limit, you will receive an "overlimit" error message from Amazon SQS. To avoid reaching the limit, delete the message from the queue after processing it.
The delay queue allows you to delay the transmission of new messages in the queue by a specific number of seconds (Delivery delay). If you create a delay queue, any messages sent to the queue are invisible to users during the delay period. Latency queues are similar to visibility timeout because both of these features make it impossible for users to obtain messages within a specific period of time. The difference between latency queue and visibility timeout is that for latency queues, messages are hidden when they are added to the queue for the first time. For visibility timeout, messages are hidden only after they are retrieved from the queue.
The difference between the default deny and the explicit deny is very important, because the default deny can be overwritten, but the explicit deny cannot. Displays the link with which a denial is sent. By default, the deny relationship is or.
Original article: http://blog.csdn.net/hongchangfirst/article/details/25877059
Author:Hongchangfirst
Hongchangfirst home: http://blog.csdn.net/hongchangfirst