Queue and Message Identifiers

SQS uses the following three identifiers that you need to be familiar with:

Queue URLs

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.

Following is the queue URL for a queue named "queue2".

http://queue.amazonaws.com/queue2

[Important]Important

In your system, always store the entire queue URL as SQS returned it to you when you created the queue (for example, http://queue.amazonaws.com/queue2). Don't build the queue URL from its separate components each time you need to specify the queue URL in a request because SQS could change the components that make up the queue URL.

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 .

Message IDs

In versions of SQS prior to 2008-01-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.

Receipt Handles

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, 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]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.

Z2hlcm1hbi5kZXNrdG9wLmFtYXpvbi5jb20=:AAABFoNJa/AAAAAAAAAANwAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAHA=