AWS SDK for .NET
Developer Guide

Sending an Amazon SQS Message

You can use the AWS SDK for .NET to send a message to an Amazon SQS queue.

Important

Due to the distributed nature of the queue, Amazon SQS can't guarantee you will receive messages in the precise order they are sent. If you need to preserve the message order, place sequencing information in each message so you can reorder the messages upon receipt.

To send a message to an Amazon SQS queue

For information about deleting messages from your queue, see Deleting a Message from an Amazon SQS Queue.

For information about receiving messages from your queue, see Receiving a Message from 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 Constructing Amazon SQS Queue URLs.

    Each queue message must be composed of Unicode characters only, and can be up to 64 KB in size. For more information about queue messages, see SendMessage in the Amazon SQS 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.

    var sendMessageResponse = sqsClient.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.