SQS uses the following three identifiers that you need to be familiar with:
Queue URL
Message ID
Receipt handle
When creating a new queue, you must provide a queue name that is unique within the scope of all your queues. If you create queues using both the 2008-01-01 WSDL and a previous version, you still have a single namespace for all your queues. SQS assigns each queue you create an identifier called a queue URL, which includes the queue name and other components that SQS determines. Whenever you want to perform an action on a queue, you provide its queue URL.
The following is the queue URL for a queue named "queue2" owned by a person with the AWS account number "123456789012".
http://queue.amazonaws.com/123456789012/queue2
![]() | Important |
|---|---|
In your system, always store the entire queue URL as Amazon SQS returned it to you when you
created the queue (for example, |
You can also get the queue URL for a queue by listing your queues. Even though you have a
single namespace for all your queues, the list of queues returned depends on the WSDL you use
for the request. For more information, see
ListQueues
.
In versions of Amazon SQS prior to 2009-02-01, each message received a system-assigned
identifier that you needed in order to delete the message from the queue. SQS still returns
this message ID to you in the
SendMessage
response, but you can no longer use the message ID to delete the message. Instead you
need a receipt handle.
Each time you receive a message from a queue, you receive a receipt handle for that message. The handle is associated with the act of receiving the message, not with the message itself. To delete the message or to change the message visibility, you must provide the receipt handle and not the message ID. This means you must always receive a message before you can delete it (you can't put a message into the queue and then recall it).
![]() | Important |
|---|---|
If you receive a message more than once, each time you receive it, you get a different receipt handle. You must provide the most recently received receipt handle when you request to delete the message or the message might not be deleted. |
Following is an example of a receipt handle.
MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+Cw Lj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QE auMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=