| Did this page help you? Yes No Tell us about it... |
Now that you've confirmed your queue exists in the Amazon SQS system, you can send a message to the
queue. The following code snippets demonstrate how to send the message This is my message
text. to your MyQueue queue.
To send a message
In the AWS Management Console select a queue.

Select Send a Message from the Queue Actions drop-down list.
![]() | Note |
|---|---|
The Queue Actions drop-down list is available only if a queue is selected. |

In the Send a Message to MyQueue dialog box, enter This is my message text.
and click Send Message.

In the Send a Message to MyQueue confirmation box click Close.

To run the sample
In the scratchpad, select SendMessage from the Explore API list box.
Enter the queue URL (which you received when you created the queue) in the Queue URL field.
Enter This is my message text. in the Message Body
field.
Select one of the following:
To invoke the request, click Invoke Request. Amazon SQS returns a response.
To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser. Amazon SQS returns a response.
To view the string to sign, click Display String to Sign.
To run the sample
Open SimpleQueueServiceSample.java.
The following section of the code sends a message to your queue:
// Send a message
System.out.println("Sending a message to MyQueue.\n");
sqs.sendMessage(new SendMessageRequest()
.withQueueUrl(myQueueUrl)
.withMessageBody("This is my message text."));Compile and run the sample.
The message This is my message text. is sent to the queue. The response includes the following items:
The message ID Amazon SQS assigns to the message
An MD5 digest of the message body, which you can use to confirm that SQS received the message correctly (for information about MD5, go to http://faqs.org/rfcs/rfc1321.html)
The request ID that Amazon SQS assigned to your request
To run the sample
Open Program.cs.
The following section of the code sends a message to your queue:
//Sending a message
Console.WriteLine("Sending a message to MyQueue.\n");
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.QueueUrl = myQueueUrl; //URL from initial queue creation
sendMessageRequest.MessageBody = "This is my message text.";
sqs.SendMessage(sendMessageRequest);Run the sample.
The message This is my message text. is sent to the queue. The response includes the following items:
The message ID Amazon SQS assigns to the message
An MD5 digest of the message body, which you can use to confirm that SQS received the message correctly (for information about MD5, go to http://faqs.org/rfcs/rfc1321.html)
The request ID that Amazon SQS assigned to your request
To run the sample
Open SendMessageSample.pl.
Locate the following line.
# invokeSendMessage($service, $request);
Replace the line with the following new lines of code.
my $request = Amazon::SQS::Model::SendMessageRequest->new({
QueueUrl => "queue URL you received from CreateQueue call",
MessageBody => "This is my message text."
});
invokeSendMessage($service, $request);Run the sample.
The message This is my message text. is sent to the queue. The response includes the following items:
The message ID Amazon SQS assigns to the message
An MD5 digest of the message body, which you can use to confirm that SQS received the message correctly (for information about MD5, go to http://faqs.org/rfcs/rfc1321.html)
The request ID that Amazon SQS assigned to your request
To run the sample
Open SendMessageSample.php.
Locate the following line.
// invokeSendMessage($service, $request);
Replace the line with the following new lines of code.
require_once ('Amazon/SQS/Model/SendMessageRequest.php');
$request = new Amazon_SQS_Model_SendMessageRequest();
$request->setQueueUrl('queue URL you received from CreateQueue call');
$request->setMessageBody('This is my message text.');
invokeSendMessage($service, $request);Run the sample.
The message This is my message text. is sent to the queue. The response includes the following items:
The message ID Amazon SQS assigns to the message
An MD5 digest of the message body, which you can use to confirm that SQS received the message correctly (for information about MD5, go to http://faqs.org/rfcs/rfc1321.html)
The request ID that Amazon SQS assigned to your request