Messages in one queue are stored on different servers, and each message has multiple replicas, achieving high reliability and availability.
Figure 1 shows how messages from a queue are distributed across different servers.
Message queues have the following characteristics:
Normal queues provide higher concurrence. However, messages may be retrieved out of sequence, because message queues are distributed in different partitions. To preserve the sequence, sequence information must be included in each message. This allows messages to be sequenced after they are received.
In a FIFO queue, messages are retrieved in the order they were sent. FIFO queues are useful in scenarios where the order of messages is important.
In rare cases, a server storing message replicas may be unavailable when the client requests or deletes messages. If this happens, the message replicas will not be deleted from that server and may be sent when the connection is restored.
This process is called "at-least-once" delivery. To avoid any adverse impact from processing the same message multiple times, ensure that your application processes messages idempotently.
When there are only a few messages in a queue, the number of messages retrieved at a time may be less than the message quantity specified in the retrieval request. However, all messages in the queue will eventually be obtained by the consumer after multiple rounds of retrieval.