Interface DeadLetter<M extends Message>

Type Parameters:
M - The type of Message represented by this interface.
All Known Implementing Classes:
GenericDeadLetter, JdbcDeadLetter, JpaDeadLetter

public interface DeadLetter<M extends Message>
Interface describing a dead lettered Message implementation of generic type M.

The time of storing the message() is kept through enqueuedAt(). The last time this letter was accessed on either SequencedDeadLetterQueue.requeue(DeadLetter, UnaryOperator, org.axonframework.messaging.core.unitofwork.ProcessingContext) or processing, is kept in lastTouched(). Additional information on why the letter is enqueued can be found in the diagnostics.

Since:
4.6.0
Author:
Steven van Beelen, Allard Buijze
  • Field Details

  • Method Details

    • fromContext

      static Optional<DeadLetter<?>> fromContext(Context context)
      Returns an Optional of {DeadLetter}, returning the resource keyed under the RESOURCE_KEY in the given context.
      Parameters:
      context - the Context to retrieve the DeadLetter from, if present
      Returns:
      an Optional of {DeadLetter}, returning the resource keyed under the RESOURCE_KEY in the given context
    • message

      M message()
      The Message of type M contained in this letter.
      Returns:
      the Message of type M contained in this letter
    • cause

      Optional<Cause> cause()
      The cause for the message() to be dead lettered. Can be an Optional.empty() in case this letter is enqueued without a causal error. For instance, when another letter already present in the queue was blocking it being handled.
      Returns:
      the cause for the message() to be dead lettered
    • enqueuedAt

      Instant enqueuedAt()
      The moment in time when the message() was entered in a dead letter queue.
      Returns:
      the moment in time when the message() was entered in a dead letter queue
    • lastTouched

      Instant lastTouched()
      The moment in time when this letter was last touched. Will equal the enqueuedAt() value if this letter is enqueued for the first time.
      Returns:
      the moment in time when this letter was last touched
    • diagnostics

      Metadata diagnostics()
      The diagnostic Metadata concerning this letter.
      Returns:
      the diagnostic Metadata concerning this letter
    • markTouched

      DeadLetter<M> markTouched()
      Construct a copy of this DeadLetter, replacing the lastTouched() with the current time.
      Returns:
      a copy of this DeadLetter with lastTouched() set to now
    • withCause

      DeadLetter<M> withCause(Throwable requeueCause)
      Construct a copy of this DeadLetter, replacing the cause() with the given requeueCause.
      Parameters:
      requeueCause - the new cause of the DeadLetter under construction
      Returns:
      a copy of this DeadLetter, replacing the cause() with the given requeueCause
    • withDiagnostics

      DeadLetter<M> withDiagnostics(Metadata diagnostics)
      Construct a copy of this DeadLetter, replacing the diagnostics() with the given diagnostics.
      Parameters:
      diagnostics - the diagnostic Metadata to append to the DeadLetter under construction
      Returns:
      a copy of this DeadLetter, replacing the diagnostics() with the given diagnostics
    • withDiagnostics

      default DeadLetter<M> withDiagnostics(UnaryOperator<Metadata> diagnosticsBuilder)
      Construct a copy of this DeadLetter, replacing the diagnostics() with the result of the given diagnosticsBuilder. The diagnosticsBuilder will be invoked with the diagnostics of this instance.
      Parameters:
      diagnosticsBuilder - the lambda constructing diagnostic Metadata to replace the Metadata of the DeadLetter under construction.
      Returns:
      a copy of this DeadLetter, replacing the diagnostics() with the result of the given diagnosticsBuilder
    • context

      default Context context()
      Returns the Context associated with this dead letter, carrying resources that were present in the ProcessingContext when the letter was enqueued. Defaults to Context.empty() if not overridden.

      The following resources are stored and restored through this context:

      Returns:
      the Context associated with this dead letter
    • position

      default OptionalLong position()
      Returns the position of this dead letter in the event stream it originated on, based on the TrackingToken in its context, when present.

      A WrappedToken is unwrapped to the position of the underlying event.

      Returns:
      the position of this dead letter, or empty when its context holds no TrackingToken, or that token has no position