Interface DecodeErrorStrategy
-
- All Implemented Interfaces:
public interface DecodeErrorStrategyWhat a subscription does with a message it cannot decode.
The dead-letter subject travels with DeadLetter rather than sitting in a separate nullable parameter, so "dead-letter selected but no subject given" is not a state a call site can write.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classDecodeErrorStrategy.SkipAndLogLog a warning and drop the message (the default).
On JetStream the message is also terminated, so the server stops redelivering it - a payload no codec can read will not decode any better on the next attempt, and leaving it unacknowledged would replay it every
ackWaitfor as long as the consumer exists.public classDecodeErrorStrategy.ThrowFail the flow with a DecodeException, after terminating the message on JetStream.
Use in development and testing to surface serialization mismatches immediately.
public final classDecodeErrorStrategy.DeadLetterRepublish the raw undecodable message to subject, then drop it from this subscription.
The dead-lettered message carries the original payload and headers plus the provenance headers in DeadLetterHeaders.
subject must be captured by a stream. On JetStream the dead letter is published as a JetStream message, and the original is terminated only once the server has acknowledged storing it - so a dead letter that never lands cannot take the original down with it. The flip side is that a dead-letter subject with no stream behind it holds every undecodable message unacknowledged for redelivery, which
subscribeandpullreject up front rather than let you discover one message at a time.On core NATS there is no stream and no acknowledgement to wait for: the dead letter is a core publish, and reaches only whatever is listening on subject at that moment.
-