Enabling Long Polling for Amazon SQS Message Queues

Amazon SQS uses short polling by default, querying only a subset of the servers—based on a weighted
random distribution—to determine whether any messages are available for inclusion
in the response.

Long polling helps reduce your cost of using Amazon SQS by reducing the number of
empty responses when
there are no messages available to return in reply to a ReceiveMessage request sent
to an Amazon SQS
queue and eliminating false empty responses. You can set a long polling frequency
from 1–20
seconds.

Enable Long Polling when Creating a Queue

To enable long polling when creating an Amazon SQS queue, set the ReceiveMessageWaitTimeSeconds
attribute on the CreateQueueRequest object before calling the SQSClient class'
CreateQueue member function.

Enable Long Polling on an Existing Queue

In addition to enabling long polling when creating a queue, you can also enable it
on an existing
queue by setting ReceiveMessageWaitTimeSeconds on the SetQueueAttributesRequest before calling the SQSClient class'
SetQueueAttributes member function.