

# Amazon SQS FIFO queues
<a name="sqs-fifo-queues"></a>

FIFO (First-In-First-Out) queues have all the capabilities of the [standard queues](standard-queues.md), but are designed to enhance messaging between applications when the order of operations and events is critical, or where duplicates can't be tolerated.

The most important features of FIFO queues are [*FIFO (First-In-First-Out) delivery*](FIFO-queues-understanding-logic.md) and *[exactly-once processing](FIFO-queues-exactly-once-processing.md)*:
+ The order in which messages are sent and received is strictly preserved and a message is delivered once and remains unavailable until a consumer processes and deletes it.
+ Duplicates aren't introduced into the queue.

Additionally, FIFO queues support *message groups* that allow multiple ordered message groups within a single queue. There is no quota to the number of message groups within a FIFO queue.

Examples of situations where you might use FIFO queues include the following:

1. E-commerce order management system where order is critical

1. Integrating with a third-party systems where events need to be processed in order

1. Processing user-entered inputs in the order entered

1. Communications and networking – Sending and receiving data and information in the same order

1. Computer systems – Making sure that user-entered commands are run in the right order

1. Educational institutes – Preventing a student from enrolling in a course before registering for an account

1. Online ticketing system – Where tickets are distributed on a first come first serve basis

**Note**  
FIFO queues also provide exactly-once processing, but have a limited number of transactions per second (TPS). You can use Amazon SQS **high throughput** mode with your FIFO queue to increase your transaction limit. For details on using high throughput mode, see [High throughput for FIFO queues in Amazon SQS](high-throughput-fifo.md). For information on throughput quotas, see [Amazon SQS message quotas](quotas-messages.md).

Amazon SQS FIFO queues are available in all Regions where Amazon SQS is available.

For more on using FIFO queues with complex ordering, see [Solving Complex Ordering Challenges with Amazon SQS FIFO Queues](https://aws.amazon.com/blogs/compute/solving-complex-ordering-challenges-with-amazon-sqs-fifo-queues/). 

For information about how to create and configure queues using the Amazon SQS console, see [Creating a standard queue using the Amazon SQS console](creating-sqs-standard-queues.md#step-create-standard-queue). For Java examples, see [Amazon SQS Java SDK examples](sqs-java-tutorials.md).

For best practices for working with FIFO queues, see [Amazon SQS best practices](sqs-best-practices.md).

# Amazon SQS FIFO queue key terms
<a name="FIFO-key-terms"></a>

The following key terms can help you better understand the functionality of FIFO queues. For more information, see the *[Amazon Simple Queue Service API Reference](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/)*.

**Clients**  
The Amazon SQS Buffered Asynchronous Client doesn't currently support FIFO queues.

**Message deduplication ID**  
A token used in Amazon SQS FIFO queues to uniquely identify messages and prevent duplication. If multiple messages with the same deduplication ID are sent within a 5 minute deduplication interval, they are treated as duplicates, and only one copy is delivered. If you don't specify a deduplication ID and content-based deduplication is enabled, Amazon SQS generates a deduplication ID by hashing the message body. This mechanism ensures exactly-once delivery by eliminating duplicate messages within the specified time frame.  
Amazon SQS continues tracking the deduplication ID even after the message has been received and deleted.

**Message group ID**  
In FIFO (First-In-First-Out) queues, `MessageGroupId` is an attribute that organizes messages into distinct groups. Messages within the same message group are always processed one at a time, in strict order, ensuring that no two messages from the same group are processed simultaneously. In standard queues, using `MessageGroupId` enables [fair queues](sqs-fair-queues.md). If strict ordering is required, use a FIFO queue.

**Receive request attempt ID**  
The receive request attempt ID is a unique token used to deduplicate [https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html) calls in Amazon SQS.

**Sequence number**  
The large, non-consecutive number that Amazon SQS assigns to each message.

**Services**  
If your application uses multiple AWS services, or a mix of AWS and external services, it is important to understand which service functionality doesn't support FIFO queues.  
Some AWS or external services that send notifications to Amazon SQS might not be compatible with FIFO queues, despite allowing you to set a FIFO queue as a target.  
The following features of AWS services aren't currently compatible with FIFO queues:  
+ [Amazon S3 Event Notifications](https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html)
+ [Auto Scaling Lifecycle Hooks](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html)
+ [AWS IoT Rule Actions](https://docs.aws.amazon.com/iot/latest/developerguide/iot-rule-actions.html)
+ [AWS Lambda Dead-Letter Queues](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)
For information about compatibility of other services with FIFO queues, see your service documentation.

# FIFO queue delivery logic in Amazon SQS
<a name="FIFO-queues-understanding-logic"></a>

The following concepts clarify how Amazon SQS FIFO queues handle the sending and receiving of messages, particularly when dealing with message ordering and message group IDs.

## Sending messages
<a name="FIFO-sending-messages"></a>

Amazon SQS FIFO queues preserve message order using unique deduplication IDs and message group IDs. This topic highlights the importance of message group IDs for maintaining strict ordering within groups and highlights best practices for ensuring reliable, ordered message delivery across multiple producers.

1. **Order preservation**
   + When multiple messages are sent in succession to a FIFO queue with unique message deduplication IDs, Amazon SQS stores them and acknowledges their transmission. These messages are then received and processed in the exact order they were transmitted.

1. **Message group ID**
   + In FIFO queues, messages are ordered based on their message group ID. If multiple producers or threads send messages with the same message group ID, Amazon SQS ensures they are stored and processed in the order they arrive.
   + Best practice: To guarantee strict message order across multiple producers, assign a unique message group ID for all messages from each producer.

1. **Per-group ordering**
   + **FIFO queue logic applies on a per message group ID basis:**
     + Each message group ID represents a distinct, ordered group of messages.
     + Within a message group ID, all messages are sent and received in strict order.
     + Messages with different message group IDs may arrive or be processed out of order relative to one another.
   + **Requirement** - You must associate a message group ID with each message. If a message is sent without a group ID, the action fails.
   + **Single group scenario** - If you require all messages to be processed in strict order, use the same message group ID for every message.

## Receiving messages
<a name="FIFO-receiving-messages"></a>

Amazon SQS FIFO queues handle message retrieval, including batch processing, FIFO order guarantees, and limitations on requesting specific message group IDs. This topic explains how Amazon SQS retrieves messages within and across message group IDs while maintaining strict ordering and visibility rules.

1. **Batch retrieval**
   + When receiving messages from a FIFO queue with multiple message group IDs, Amazon SQS:
     + Attempts to return as many messages as possible with the same message group ID in a single call.
     + Allows other consumers to process messages from different message group IDs concurrently.
   + **Important clarification**
     + You may receive multiple messages from the same message group ID in one batch (up to 10 messages in a single call using the `MaxNumberOfMessages` parameter).
     + However, you can't receive additional messages from the same message group ID in subsequent requests until:
       + The currently received messages are deleted, or
       + They become visible again (for example, after the visibility timeout expires).

1. **FIFO order guarantee**
   + Messages retrieved in a batch retain their FIFO order within the group.
   + If fewer than 10 messages are available for the same message group ID, Amazon SQS may include messages from other message group IDs in the same batch, but each group retains FIFO order.

1. **Consumer limitations**
   + You cannot explicitly request to receive messages from a specific message group ID.

## Retrying multiple times
<a name="FIFO-retrying-multiple-times"></a>

Producers and consumers can safely retry failed actions in Amazon SQS FIFO queues without disrupting message order or introducing duplicates. This topic highlights how deduplication IDs and visibility timeouts ensure message integrity during retries.

1. **Producer retries**
   + If a [https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html) action fails, the producer can retry sending the message multiple times with the same message deduplication ID.
   + As long as the producer receives at least one acknowledgment before the deduplication interval expires, retries:
     + Do not introduce duplicate messages.
     + Do not disrupt message order.

1. **Consumer retries**
   + If a [https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html) action fails, the consumer can retry as many times as necessary using the same receive request attempt ID.
   + As long as the consumer receives at least one acknowledgment before the visibility timeout expires, retries:
     + Do not disrupt message order.

## Additional notes on FIFO behavior
<a name="FIFO-behavior"></a>

Learn about handling visibility timeouts, enabling parallel processing with multiple message group IDs, and ensuring strict sequential processing in single-group scenarios.

1. **Handling visibility timeout**
   + When a message is retrieved but not deleted, it remains invisible until the visibility timeout expires.
   + No additional messages from the same message group ID are returned until the first message is deleted or becomes visible again.

1. **Concurrency and parallel processing**
   + FIFO queues allow parallel processing of messages across different message group IDs.
   + To maximize concurrency, design your system with multiple message group IDs for independent workflows.

1. **Single group scenarios**
   + For strict sequential processing of all messages in a FIFO queue, use a single message group ID for all messages in the queue.

## Examples for better understanding
<a name="FIFO-examples"></a>

The following are practical scenarios illustrating FIFO queue behavior in Amazon SQS.

1. **Scenario 1: Single group ID**
   + A producer sends five messages with the same message group ID Group A.
   + A consumer receives these messages in FIFO order. Until the consumer deletes these messages or the visibility timeout expires, no additional messages from Group A are received.

1. **Scenario 2: Multiple group IDs**
   + A producer sends five messages to Group A and 5 to Group B.
   + Consumer 1 processes messages from Group A, while Consumer 2 processes messages from Group B. This enables parallel processing with strict ordering maintained within each group.

1. **Scenario 3: Batch retrieval**
   + A producer sends seven messages to Group A and three to Group B.
   + A single consumer retrieves up to 10 messages. If the queue allows, it may return:
     + Seven messages from Group A and three from Group B (or fewer if fewer messages are available from a single group).

# Exactly-once processing in Amazon SQS
<a name="FIFO-queues-exactly-once-processing"></a>

Unlike standard queues, FIFO queues don't introduce duplicate messages. FIFO queues help you avoid sending duplicates to a queue. If you retry the `SendMessage` action within the 5-minute deduplication interval, Amazon SQS doesn't introduce any duplicates into the queue.

To configure deduplication, you must do one of the following:
+ Enable content-based deduplication. This instructs Amazon SQS to use a SHA-256 hash to generate the message deduplication ID using the body of the message—but not the attributes of the message. For more information, see the documentation on the `[CreateQueue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html)`, `[GetQueueAttributes](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_GetQueueAttributes.html)`, and `[SetQueueAttributes](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html)` actions in the *Amazon Simple Queue Service API Reference*.
+ Explicitly provide the message deduplication ID (or view the sequence number) for the message. For more information, see the documentation on the `[SendMessage](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html)`, `[SendMessageBatch](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessageBatch.html)`, and `[ReceiveMessage](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html)` actions in the *Amazon Simple Queue Service API Reference*.

# Moving from a standard queue to a FIFO queue in Amazon SQS
<a name="FIFO-queues-moving"></a>

If your existing application uses standard queues and you want to take advantage of the ordering or exactly-once processing features of FIFO queues, you need to configure both the queue and your application correctly.

**Key considerations**
+ **Creating a FIFO Queue:** You cannot convert an existing standard queue into a FIFO queue. You must either create a new FIFO queue for your application or delete the existing standard queue and recreate it as a FIFO queue.
+ **Delay Parameter:** FIFO queues do not support per-message delays, only per-queue delays. If your application sets the `DelaySeconds` parameter on each message, you must modify it to set `DelaySeconds` on the entire queue instead.
+ **Message Group ID:** Provide a [message group ID](high-throughput-fifo.md#partitions-and-data-distribution) for every sent message. This ID enables parallel processing of messages while maintaining their respective order. Use a granular business dimension for the message group ID to better scale with FIFO queues. The more message group IDs you distribute messages to, the greater the number of messages available for consumption.
+ **High Throughput Mode:** Use the recommended [high throughput mode](high-throughput-fifo.md#partitions-and-data-distribution) for FIFO queues to achieve increased throughput. For more information on messaging quotas, see [Amazon SQS message quotas](quotas-messages.md).

**Checklist for moving to FIFO queues**

Before sending messages to a FIFO queue, confirm the following:

1. **Configure delay settings**
   + Modify your application to remove per-message delays.
   + Set the `DelaySeconds` parameter on the entire queue.

1. **Set message group IDs**
   + Organize messages into message groups by specifying a message group ID based on a business dimension.
   + Use more granular business dimensions to improve scalability.

1. **Handle message deduplication**
   + If your application can't send messages with identical message bodies, provide a unique message deduplication ID for each message.
   + If your application sends messages with unique message bodies, enable content-based deduplication.

1. **Configure the consumer**
   + Generally, no code changes are needed for the consumer.
   + If processing messages takes a long time and the visibility timeout is set high, consider adding a receive request attempt ID to each `ReceiveMessage` action. This helps retry receive attempts in case of networking failures and prevents queues from pausing due to failed receive attempts.

By following these steps, you can ensure your application works correctly with FIFO queues, taking full advantage of their ordering and exactly-once processing features. For more detailed information, see the * [Amazon Simple Queue Service API Reference](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/)*.

# Amazon SQS FIFO queue and Lambda concurrency behavior
<a name="fifo-queue-lambda-behavior"></a>

By using a FIFO (First-In-First-Out) queue with Lambda, you can ensure ordered processing of messages within each message group. The Lambda function will not run multiple instances for the same message group simultaneously, thereby maintaining the order. However, it can scale up to handle multiple message groups in parallel, ensuring efficient processing of your queue's workload. The following points describe the behavior of Lambda functions when processing messages from an Amazon SQS FIFO queue with respect to message group IDs:
+ **Single instance per message group:** At any point in time, only one Lambda instance will be processing messages from a specific message group ID. This ensures that messages within the same group are processed in order, maintaining the integrity of the FIFO sequence.
+ **Concurrent processing of different groups:** Lambda can concurrently process messages from different message group IDs using multiple instances. This means that while one instance of the Lambda function is handling messages from one message group ID, other instances can simultaneously handle messages from other message group IDs, leveraging the concurrency capabilities of Lambda to process multiple groups in parallel.

## FIFO queue message grouping
<a name="fifo-queue-message-grouping"></a>

FIFO queues ensure that messages are processed in the exact order they are sent. They use a **message group ID** to group messages that should be processed sequentially.

Messages within the same message group are processed in order, and only one message from each group is processed at a time to maintain this order.

## Lambda concurrency with FIFO queues
<a name="lambda-concurrency-fifo-queues"></a>

After you create your queue, you can send a message to it.

When you set up a Lambda function to process messages from an Amazon SQS FIFO queue, Lambda respects the ordering guarantees provided by the FIFO queue. The following points describe the behavior of Lambda functions in terms of concurrency and scaling when processing messages from an Amazon SQS FIFO queue when using message group IDs.
+ **Concurrency within message groups:** Only one Lambda instance processes messages for a particular message group ID at a time. This ensures that messages within a group are handled sequentially.
+ **Scaling and multiple message groups:**While Lambda can scale up to process messages concurrently, this scaling occurs across different message groups. If you have multiple message groups, Lambda can process multiple groups in parallel, with each group being handled by a separate Lambda instance.

For more information, see [Scaling and concurrency in Lambda](https://docs.aws.amazon.com/lambda/latest/operatorguide/scaling-concurrency.html) in the *AWS Lambda Operator Guide*.

## Use case example
<a name="lambda-concurrency-fifo-queues-example"></a>

Suppose your FIFO queue receives messages with the same message group ID, and your Lambda function has a high concurrency limit (up to 1000).

If a message from group ID 'A' is being processed and another message from group ID 'A' arrives, the second message will not trigger a new Lambda instance until the first message is fully processed.

However, if messages from group IDs 'A' and 'B' arrive, both messages can be processed concurrently by separate Lambda instances.

# High throughput for FIFO queues in Amazon SQS
<a name="high-throughput-fifo"></a>

High throughput FIFO queues in Amazon SQS efficiently manage high message throughput while maintaining strict message order, ensuring reliability and scalability for applications processing numerous messages. This solution is ideal for scenarios demanding both high throughput and ordered message delivery.

Amazon SQS high throughput FIFO queues are not necessary in scenarios where strict message ordering is not crucial and where the volume of incoming messages is relatively low or sporadic. For instance, if you have a small-scale application that processes infrequent or non-sequential messages, the added complexity and cost associated with high throughput FIFO queues may not be justified. Additionally, if your application does not require the enhanced throughput capabilities provided by high throughput FIFO queues, opting for a standard Amazon SQS queue might be more cost-effective and simpler to manage.

To enhance request capacity in high throughput FIFO queues, increasing the number of message groups is recommended. For more information on high throughput message quotas, see [Amazon SQS service quotas](https://docs.aws.amazon.com/general/latest/gr/sqs-service.html#limits_sqs.html) in the *Amazon Web Services General Reference*.

For information per-queue quotas and data distribution strategies, see [Amazon SQS message quotas](quotas-messages.md) and [Partitions and data distribution for high throughput for SQS FIFO queues](#partitions-and-data-distribution).

## Use cases for high throughput for Amazon SQS FIFO queues
<a name="high-throughput-fifo-use-cases"></a>

The following use cases highlight the diverse applications of high throughput FIFO queues, showcasing their effectiveness across industries and scenarios:

1. **Real-time data processing: **Applications dealing with real-time data streams, such as event processing or telemetry data ingestion, can benefit from high throughput FIFO queues to handle the continuous influx of messages while preserving their order for accurate analysis.

1. **E-commerce order processing:** In e-commerce platforms where maintaining the order of customer transactions is critical, high throughput FIFO queues ensure that orders are processed sequentially and without delays, even during peak shopping seasons.

1. **Financial services:** Financial institutions handling high-frequency trading or transactional data rely on high throughput FIFO Queues to process market data and transactions with minimal latency while adhering to strict regulatory requirements for message ordering.

1. **Media streaming: **Streaming platforms and media distribution services utilize high throughput FIFO queues to manage the delivery of media files and streaming content, ensuring smooth playback experiences for users while maintaining the correct order of content delivery.

## Partitions and data distribution for high throughput for SQS FIFO queues
<a name="partitions-and-data-distribution"></a>

Amazon SQS stores FIFO queue data in partitions. A *partition* is an allocation of storage for a queue that is automatically replicated across multiple Availability Zones within an AWS Region. You don't manage partitions. Instead, Amazon SQS handles partition management.

For FIFO queues, Amazon SQS modifies the number of partitions in a queue in the following situations:
+ If the current request rate approaches or exceeds what the existing partitions can support, additional partitions are allocated until the queue reaches the regional quota. For information on quotas, see [Amazon SQS message quotas](quotas-messages.md).
+ If the current partitions have low utilization, the number of partitions may be reduced.

Partition management occurs automatically in the background and is transparent to your applications. Your queue and messages are available at all times.

### Distributing data by message group IDs
<a name="data-distribution-message-group-id"></a>

To add a message to a FIFO queue, Amazon SQS uses the value of each message’s message group ID as input to an internal hash function. The output value from the hash function determines which partition stores the message.

The following diagram shows a queue that spans multiple partitions. The queue’s message group ID is based on item number. Amazon SQS uses its hash function to determine where to store a new item; in this case, it's based on the hash value of the string `item0`. Note that the items are stored in the same order in which they are added to the queue. Each item's location is determined by the hash value of its message group ID.

![\[A queue spans multiple partitions.\]](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/images/fifo-documentation-single.png)


**Note**  
Amazon SQS is optimized for uniform distribution of items across a FIFO queue's partitions, regardless of the number of partitions. AWS recommends that you use message group IDs that can have a large number of distinct values. 

### Optimizing partition utilization
<a name="data-distribution-partition-limitations"></a>

Each partition supports up to 3,000 messages per second with batching, or up to 300 messages per second for send, receive, and delete operations in supported regions. For more information on high throughput message quotas, see [Amazon SQS service quotas](https://docs.aws.amazon.com/general/latest/gr/sqs-service.html#limits_sqs.html) in the *Amazon Web Services General Reference*.

When using batch APIs, each message is routed based on the process described in [Distributing data by message group IDs](#data-distribution-message-group-id). Messages that are routed to the same partition are grouped and processed in a single transaction.

To optimize partition utilization for the `SendMessageBatch` API, AWS recommends batching messages with the same message group IDs when possible.

To optimize partition utilization for the `DeleteMessageBatch` and `ChangeMessageVisibilityBatch` APIs, AWS recommends using `ReceiveMessage` requests with the `MaxNumberOfMessages` parameter set to 10, and batching the receipt-handles returned by a single `ReceiveMessage` request.

In the following example, a batch of messages with various message group IDs is sent. The batch is split into three groups, each of which counts against the quota for the partition.

![\[A batch of messages with different message group IDs is stored in partitions.\]](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/images/fifo-documentation-batch.png)


**Note**  
Amazon SQS only guarantees that messages with the same message group ID's internal hash function are grouped within a batch request. Depending on the output of the internal hash function and the number of partitions, messages with different message group IDs might be grouped. Since the hash function or number of partitions can change at any time, messages that are grouped at one point may not be grouped later.

# Enabling high throughput for FIFO queues in Amazon SQS
<a name="enable-high-throughput-fifo"></a>

You can enable high throughput for any new or existing FIFO queue. The feature includes three new options when you create and edit FIFO queues:
+ **Enable high throughput FIFO** – Makes higher throughput available for messages in the current FIFO queue.
+ **Deduplication scope** – Specifies whether deduplication occurs at the queue or message group level.
+ **FIFO throughput limit** – Specifies whether the throughput quota on messages in the FIFO queue is set at the queue or message group level.

**To enable high throughput for a FIFO queue (console)**

1. Start [creating](creating-sqs-standard-queues.md#step-create-standard-queue) or [editing](sqs-configure-edit-queue.md) a FIFO queue.

1. When specifying options for the queue, choose **Enable high throughput FIFO**.

   Enabling high throughput for FIFO queues sets the related options as follows:
   + **Deduplication scope** is set to **Message group**, the required setting for using high throughput for FIFO queues.
   + **FIFO throughput limit** is set to **Per message group ID**, the required setting for using high throughput for FIFO queues.

   If you change any of the settings required for using high throughput for FIFO queues, normal throughput is in effect for the queue, and deduplication occurs as specified.

1. Continue specifying all options for the queue. When you finish, choose **Create queue** or **Save**.

After creating or editing the FIFO queue, you can [send messages](creating-sqs-standard-queues.md#sqs-send-messages) to it and [receive and delete messages](step-receive-delete-message.md), all at a higher TPS. For high throughput quotas, see Message throughput in [Amazon SQS message quotas](quotas-messages.md).

# FIFO queue and message identifiers in Amazon SQS
<a name="sqs-fifo-queue-message-identifiers"></a>

This section describes the identifiers of FIFO queues. These identifiers can help you find and manipulate specific queues and messages.

## Identifiers for FIFO queues in Amazon SQS
<a name="sqs-general-identifiers"></a>

For more information about the following identifiers, see the *[Amazon Simple Queue Service API Reference](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/)*.

### Queue name and URL
<a name="fifo-queue-name-url"></a>

When you create a new queue, you must specify a queue name unique for your AWS account and region. Amazon SQS assigns each queue you create an identifier called a *queue URL* that includes the queue name and other Amazon SQS components. Whenever you want to perform an action on a queue, you provide its queue URL.

The name of a FIFO queue must end with the `.fifo` suffix. The suffix counts towards the 80-character queue name quota. To determine whether a queue is [FIFO](sqs-fifo-queues.md), you can check whether the queue name ends with the suffix.

The following is the queue URL for a FIFO queue named `MyQueue` owned by a user with the AWS account number `123456789012`.

```
https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue.fifo
```

You can retrieve the URL of a queue programmatically by listing your queues and parsing the string that follows the account number. For more information, see `[ListQueues](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ListQueues.html)`.

### Message ID
<a name="fifo-message-id"></a>

Each message receives a system-assigned *message ID* that Amazon SQS returns to you in the `[SendMessage](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html)` response. This identifier is useful for identifying messages. The maximum length of a message ID is 100 characters.

### Receipt handle
<a name="fifo-receipt-handle"></a>

Every time you receive a message from a queue, you receive a *receipt handle* for that message. This handle is associated with the action 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 (not the message ID). Thus, you must always receive a message before you can delete it (you can't put a message into the queue and then recall it). The maximum length of a receipt handle is 1,024 characters. 

**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 (otherwise, the message might not be deleted). 

The following is an example of a receipt handle (broken across three lines).

```
MbZj6wDWli+JvwwJaBV+3dcjk2YW2vA3+STFFljTM8tJJg6HRG6PYSasuWXPJB+Cw
Lj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGYWbnLmpRCJVAyeMjeU5ZBdtcQ+QE
auMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/KSbkJ0=
```

## Additional identifiers for Amazon SQS FIFO queues
<a name="sqs-additional-fifo-queue-identifiers"></a>

For more information about the following identifiers, see [Exactly-once processing in Amazon SQS](FIFO-queues-exactly-once-processing.md) and the *[Amazon Simple Queue Service API Reference](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/)*.

### Message deduplication ID
<a name="sqs-fifo-queue-messagededuplicationid"></a>

A token used in Amazon SQS FIFO queues to uniquely identify messages and prevent duplication. If multiple messages with the same deduplication ID are sent within a 5 minute deduplication interval, they are treated as duplicates, and only one copy is delivered. If you don't specify a deduplication ID and content-based deduplication is enabled, Amazon SQS generates a deduplication ID by hashing the message body. This mechanism ensures exactly-once delivery by eliminating duplicate messages within the specified time frame.

### Message group ID
<a name="sqs-fifo-queue-messagegroupid"></a>

The `MessageGroupId` is an attribute used only in Amazon SQS FIFO (First-In-First-Out) queues to organize messages into distinct groups. Messages within the same message group are always processed one at a time, in strict order, ensuring that no two messages from the same group are processed simultaneously. Standard queues do not use `MessageGroupId` and do not provide ordering guarantees. If strict ordering is required, use a FIFO queue instead.

### Sequence number
<a name="sqs-fifo-queue-sequence-number"></a>

The large, non-consecutive number that Amazon SQS assigns to each message.