跳到主要内容
本页尚未翻译

下面显示的是英文原文。

Channels

Each channel carries an sqs binding: the queue's name and FIFO flag, and the polling settings a subscription names.

The binding holds one queue object. name is the queue's name, and fifoQueue is true for a name ending in .fifo, the suffix that makes a queue FIFO. A subscription's channel adds receiveMessageWaitTime, the long-poll wait in seconds, 20 unless the descriptor names another. It adds visibilityTimeout when the descriptor names a visibility; the queue's own timeout takes a connection to read, so the document leaves it out.

A channel the service publishes to through SqsPublish reports the queue the mount site resolved. That is a reply("dest") clause, a reply type's #[outgoing(name)], or the name of a slot entry. Its binding has name and fifoQueue only: the polling belongs to the subscription that reads the queue.

Example​

The channel orders reports its queue and both polling settings, and shipments.fifo a FIFO queue polled with the default wait. The channel confirmations reports the queue the reply clause names.

#[subscriber(
SqsQueue::new("orders")
.wait(Duration::from_secs(10))
.visibility(Duration::from_secs(30)),
reply("confirmations")
)]
async fn confirm(order: &Order) -> Confirmation {
Confirmation { id: order.id }
}

#[subscriber(SqsQueue::new("shipments.fifo"))]
async fn ship(order: &Order) -> HandlerOutcome {
tracing::info!(order.id, "shipped");
HandlerOutcome::ack()
}

The binding of orders in the document:

{
"sqs": {
"bindingVersion": "0.3.0",
"queue": {
"name": "orders",
"fifoQueue": false,
"visibilityTimeout": 30,
"receiveMessageWaitTime": 10
}
}
}