AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
A map of attributes to set.
The following lists the names, descriptions, and values of the special request parameters the
SetQueueAttributesaction uses:
DelaySeconds- The time in seconds that the delivery of all messages in the queue will be delayed. An integer from 0 to 900 (15 minutes). The default for this attribute is 0 (zero).
MaximumMessageSize- The limit of how many bytes a message can contain before Amazon SQS rejects it. An integer from 1024 bytes (1 KiB) up to 262144 bytes (256 KiB). The default for this attribute is 262144 (256 KiB).
MessageRetentionPeriod- The number of seconds Amazon SQS retains a message. Integer representing seconds, from 60 (1 minute) to 1209600 (14 days). The default for this attribute is 345600 (4 days).
Policy- The queue's policy. A valid AWS policy. For more information about policy structure, see Overview of AWS IAM Policies in the Amazon IAM User Guide.
ReceiveMessageWaitTimeSeconds- The time for which a ReceiveMessage call will wait for a message to arrive. An integer from 0 to 20 (seconds). The default for this attribute is 0.
VisibilityTimeout- The visibility timeout for the queue. An integer from 0 to 43200 (12 hours). The default for this attribute is 30. For more information about visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide.
RedrivePolicy- The parameters for dead letter queue functionality of the source queue. For more information about RedrivePolicy and dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide.
Namespace: Amazon.SQS.Model
Assembly: AWSSDK.dll
Version: 0.0.3.0
public Dictionary<String, String> Attributes { get; set; }
This example shows how to set queue attributes.
var client = new AmazonSQSClient();
var attrs = new Dictionary<string, string>();
// Maximum message size of 128 KiB (1,024 bytes * 128 KiB = 131,072 bytes).
int maxMessage = 128 * 1024;
attrs.Add(QueueAttributeName.DelaySeconds,
TimeSpan.FromSeconds(5).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.MaximumMessageSize, maxMessage.ToString());
attrs.Add(QueueAttributeName.MessageRetentionPeriod,
TimeSpan.FromDays(1).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.ReceiveMessageWaitTimeSeconds,
TimeSpan.FromSeconds(5).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.VisibilityTimeout,
TimeSpan.FromHours(1).TotalSeconds.ToString());
// Dead-letter queue attributes.
attrs.Add(QueueAttributeName.RedrivePolicy,
"{\"maxReceiveCount\":" +
"\"5\"," +
"\"deadLetterTargetArn\":" +
"\"arn:aws:sqs:us-east-1:80398EXAMPLE:MyTestDeadLetterQueue\"}");
var request = new SetQueueAttributesRequest
{
Attributes = attrs,
QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue"
};
client.SetQueueAttributes(request);
.NET Framework:
Supported in: 4.5, 4.0, 3.5
.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8
.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8