Skip to main content

Module dead_letter

Module dead_letter 

Source
Expand description

Dead-letter sink for unroutable or unprocessable inbound messages.

BDEW AS4 requires that every received message is either processed or explicitly refused (CONTRL negative acknowledgement). Messages that cannot be routed to a workflow — because the PID is unknown, the conversation is not in-flight, or the format version has no adapter — must not be silently dropped.

§Design

DeadLetterSink is a synchronous trait that receives a structured DeadLetterReason for every rejected message. The synchronous contract keeps dispatch-path hot code fast; implementations that need async work (e.g. persisting to a durable DLQ or sending a CONTRL) can use tokio::spawn internally.

§Implementations

TypeBehaviour
LogDeadLetterSinkEmits structured tracing::warn!; suitable for all deployments
NoopDeadLetterSinkSilently discards; only for testing

§Wiring

Pass an implementation to EngineBuilder::with_dead_letter_sink. The default is LogDeadLetterSink so unroutable messages are always visible in the log output without any configuration.

use mako_engine::dead_letter::{AuditContext, DeadLetterReason, DeadLetterSink, LogDeadLetterSink};

let sink = LogDeadLetterSink;
sink.reject(&DeadLetterReason::UnknownPid { pid: 99999, context: AuditContext::now() });

Structs§

AuditContext
Structured audit context attached to every dead-letter event.
LogDeadLetterSink
A DeadLetterSink that emits a structured tracing::warn! event for every rejected message.
NoopDeadLetterSink
A DeadLetterSink that silently discards all rejected messages.

Enums§

DeadLetterReason
Structured reason why an inbound message was rejected.

Traits§

DeadLetterSink
Receives messages that cannot be routed or processed.