onDeliveryFailure
onDeliveryFailure is a callback or event in asynchronous message delivery systems that is triggered when an attempted delivery cannot be completed due to an error. It is commonly provided by client libraries or frameworks that implement producer-side delivery guarantees, and it complements success and retry semantics by offering a hook to handle unrecoverable failures.
The handler typically receives contextual information such as an error object or exception, an identifier for
On invocation, the onDeliveryFailure handler is expected to perform remediation. Common actions include logging the failure,
This pattern is used across messaging and eventing stacks, including Kafka-like producers, AMQP, MQTT clients, and
Design considerations include thread safety, avoiding side effects in the callback, preserving message identity for deduplication,
In practice, developers wire onDeliveryFailure to their error handling and monitoring systems, choosing between logging, dead-lettering,