An application needs to make use of the SQS service for sending and receiving messages.
The application takes 60 seconds to process a message.
Assuming that a queue has been created with the default settings, which one of the following must be implemented?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A.
The AWS Documentation mentions the following.
Changes the visibility timeout of a specified message in a queue to a new value.
The default visibility timeout for a message is 30 seconds.
The minimum is 0 seconds.
The maximum is 12 hours.
For example, you have a message with a visibility timeout of 5 minutes.
After 3 minutes, you call ChangeMessageVisibility with a timeout of 10 minutes.
You can continue to call ChangeMessageVisibility to extend the visibility timeout to the maximum allowed time.
If you try to extend the visibility timeout beyond the maximum, your request is rejected.
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dg.pdfOptions B and D are incorrect since you first need to call ChangeMessageVisibility API.
Option C is incorrect since the ChangeMessageVisibility API should be used to increase the timeout.
For more information on the visibility timeout, please refer to the below URL-
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ChangeMessageVisibility.htmlThe correct answer is A. Call the ChangeMessageVisibility API and increase the timeout.
Explanation: Amazon SQS (Simple Queue Service) is a fully managed message queuing service that enables decoupling and scalability of microservices, distributed systems, and serverless applications. In SQS, messages are stored in a queue until they are processed by a consumer.
When a message is retrieved by a consumer, SQS sets an invisible timeout period, called the visibility timeout, during which the message is hidden from other consumers. This is done to prevent multiple consumers from processing the same message at the same time. If the message is processed within this timeout period, it is deleted from the queue. Otherwise, it becomes visible again and can be retrieved by another consumer.
In this scenario, the application takes 60 seconds to process a message, which means that the visibility timeout needs to be increased to more than 60 seconds to ensure that the message is not visible to other consumers before it is fully processed.
Option A is the correct answer because it suggests calling the ChangeMessageVisibility API and increasing the timeout. This API allows the visibility timeout of a message to be changed, so the message remains hidden from other consumers until the application completes processing the message. Once processing is complete, the application can call the DeleteMessage API to remove the message from the queue.
Option B is incorrect because calling the DeleteMessage API does not affect the visibility timeout of a message.
Option C is incorrect because decreasing the timeout using the ChangeMessageVisibility API would make the message visible to other consumers before it is fully processed. The message should only be deleted from the queue using the DeleteMessage API once processing is complete.
Option D is incorrect because deleting the message from the queue first using the DeleteMessage API would not allow the application enough time to process the message. The visibility timeout needs to be increased first to ensure that the message remains hidden from other consumers until processing is complete.