User guide
Table Of Contents
- AWS SDK for .NET
- Table of Contents
- AWS SDK for .NET Developer Guide
- Getting Started with the AWS SDK for .NET
- Programming with the AWS SDK for .NET
- AWS SDK for .NET Tutorials and Examples
- Managing ASP.NET Session State with Amazon DynamoDB
- Tutorial: Creating Amazon EC2 Instances with the AWS SDK for .NET
- Tutorial: Grant Access Using an IAM Role and the AWS SDK for .NET
- Tutorial: Amazon EC2 Spot Instances
- Creating and Using an Amazon SQS Queue with the AWS SDK for .NET
- Creating an Amazon Route 53 Hosted Zone and Adding Resource Record Sets
- Additional Resources
- Document History

Important
Due to the distributed nature of the queue, Amazon SQS cannot guarantee you will receive
messages in the exact order they are sent. If you require that message order be preserved,
place sequencing information in each message so you can reorder the messages upon receipt.
To send a message to an Amazon SQS queue
1. Create and initialize a SendMessageRequest instance. Specify the queue name and the message
you want to send, as follows:
sendMessageRequest.QueueUrl = myQueueURL;
sendMessageRequest.MessageBody = "YOUR_QUEUE_MESSAGE";
For more information about your queue URL, see Amazon SQS Queue URLs (p. 60).
Each queue message must be composed of only Unicode characters, and can be up to 64 kB in
size. For more information about queue messages, go to SendMessage in the Amazon SQS service
API reference.
2. After you create the request, pass it as a parameter to the SendMessage method.The method returns
a SendMessageResponse object, as follows:
SendMessageResponse sendMessageResponse =
amazonSQSClient.SendMessage(sendMessageRequest);
The sent message will stay in your queue until the visibility timeout is exceeded, or until it is deleted
from the queue. For more information about visibility timeouts, go to Visibility Timeout.
For information on deleting messages from your queue, see Delete a Message from an Amazon SQS
Queue (p. 62).
For information on receiving messages from your queue, see Receive a Message from an Amazon SQS
Queue (p. 61).
Receive a Message from an Amazon SQS Queue
You can use the Amazon SDK for .NET to receive messages from an Amazon SQS queue.
To receive a message from an Amazon SQS queue
1. Create and initialize a ReceiveMessageRequest instance. Specify the queue URL to receive a
message from, as follows:
ReceiveMessageRequest recieveMessageRequest =
new ReceiveMessageRequest();
recieveMessageRequest.QueueUrl = myQueueURL;
For more information about your queue URL, see Amazon SQS Queue URLs (p. 60).
2. Pass the request object as a parameter to the ReceiveMessage method, as follows:
Version v2.0.0
61
AWS SDK for .NET Developer Guide
Receive a Message from an Amazon SQS Queue