feat: add a NATS "dead letter queue" stream for failing messages #5035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change introduces a new NATS Jetstream stream called
DEAD_LETTER_QUEUES
which will contain metadata of messages that reached their consumer'smax_deliver
limit. Currently, only theforklift-server
consumer for theAUDIT_LOGS
stream is configured, but more streams and consumers could be configured to use this in the future.The forklift/audit logs NATS consumer is configured to attempt
4
deliveries of each message with a linear backoff (i.e. when a message isnack
d) of 5 seconds, then 10, then 15 for a total of 30 seconds before the message metadata is added to the "dead letter queue" stream. Note that a "failed" message is not deleted from its source stream, but rather skipped over by that consumer. This allows us to inspect each failed message in place in the stream and decide how to triage any remediations.