Dead Letter Envelopes


Note! You will need to use some kind of Durable Messaging and Command Processing to have the dead letter queue be persisted.

If a message cannot be processed after all its retries or if your error handling policies explicitly use the MoveToErrorQueue() functionality, those envelopes are moved out of the active queues and saved off to the side in your envelope storage.

Retrieve an Error Report

It should be easy to browse the dead letter queue tables in your Postgresql database (mt_doc_errorreport) or your Sql Server database (jasper_dead_letters). If you know the envelope id of a dead letter envelope, you can use the IEnvelopePersistor interface in the IoC container of your application to fetch the entire error report like this:


public async Task load_error_report(IEnvelopePersistence persistence, Guid envelopeId)
{
    var report = await persistence.Admin.LoadDeadLetterEnvelope(envelopeId);

    // The Id
    Console.WriteLine(report.Id);

    // Why it was moved out
    Console.WriteLine(report.Explanation);

    // The underlying message typ
    Console.WriteLine(report.MessageType);


    // Reconstitute the original Envelope
    // Envelope.Data would have the raw data here
    var envelope = report.RebuildEnvelope();

    // The name ofthe system that sent the message
    Console.WriteLine(report.Source);

    // The .Net Exception type name
    Console.WriteLine(report.ExceptionType);

    // Just the message of the exception
    Console.WriteLine(report.ExceptionMessage);

    // JUST SHOW ME THE FULL STACKTRACE ALREADY!!!!
    Console.WriteLine(report.ExceptionText);
}