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

下面显示的是英文原文。

Dead letters

max_attempts(n) caps deliveries per record; dead_letter(stream) names the stream a spent record leaves for, and a cap without one retires the record.

The cap counts the first delivery too. Kinesis keeps no delivery count, so the count travels with the record in RETRY_COUNT_HEADER. Under a cap every retry is a copy published back to the stream, the immediate retry too, because only a copy carries the count forward. When a retry would make the delivery the n-th one, the runtime settles it and publishes the record to the dead-letter stream instead, without the delay. The record keeps its payload, its headers and its partition key; its retry count says how many times it was delivered. A cap without a dead-letter stream checkpoints past the spent record, as drop does. The dead-letter stream is an ordinary stream of the service's own infrastructure: a subscription of the same service, or of another one, reads it.

Example​

An order gets four deliveries; the fourth one that still cannot be settled goes to orders.unsettled.

fn service(broker: KinesisBroker) -> RustStream {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker, |b| {
// Four deliveries per order, then the record leaves for a stream an operator reads.
b.include(reconcile)
.max_attempts(nonzero!(4))
.dead_letter("orders.unsettled");
})
}