Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

FIFO

A .fifo queue hands out each message group in order and holds a group back while one of its messages is in flight.

A queue whose name ends in .fifo is a FIFO queue, and a subscription reads it like any other queue. Every message on it belongs to a message group, which the producer names: the group_id step, the partition key header, or default when it names neither. The queue hands out the messages of a group in the order they were sent. While a message of a group is in flight, the queue holds the rest of that group back until the message is deleted or its visibility lapses. Other groups go on meanwhile. So a retry brings the same message back before the next one of its group. The delivery carries its group in PARTITION_KEY_HEADER. A FIFO queue drops a message whose deduplication id it has seen in the last five minutes. A FIFO queue takes a FIFO dead-letter queue, and create_if_missing on a .fifo name creates a FIFO queue. In process the account keeps the same order and holds a group back the same way.

Example​

The orders of one customer, fulfilled in the order they were placed.

/// Reads the FIFO queue `orders.fifo`. The orders of one customer are one message group, so
/// they arrive in the order they were sent, one at a time.
#[subscriber(SqsQueue::new("orders.fifo"))]
async fn fulfil(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, order.customer, "order fulfilled");
HandlerOutcome::ack()
}

fn service(broker: SqsBroker) -> impl App {
RustStream::new(AppInfo::new("fulfillment", "0.1.0")).with_broker(broker, |b| {
b.include(fulfil);
})
}