java.lang.Object
org.axonframework.messaging.eventhandling.deadletter.jpa.DeadLetterEntry

@Entity public class DeadLetterEntry extends Object
Default DeadLetter JPA entity implementation of dead letters. Used by the JpaSequencedDeadLetterQueue to store these into the database to be retried later.

The original message is embedded as a DeadLetterEventEntry. This is mapped, upon both storage and retrieval, by one of the configured converters.

Since:
4.6.0
Author:
Mitchell Herrijgers
  • Constructor Details

    • DeadLetterEntry

      protected DeadLetterEntry()
      Constructor required by JPA. Do not use.
    • DeadLetterEntry

      public DeadLetterEntry(String processingGroup, String sequenceIdentifier, long sequenceIndex, DeadLetterEventEntry message, Instant enqueuedAt, Instant lastTouched, Cause cause, Metadata diagnostics, Converter converter)
      Creates a new DeadLetterEntry consisting of the given parameters.
      Parameters:
      processingGroup - The processing group this message belongs to.
      sequenceIdentifier - The sequence identifier this message belongs to.
      sequenceIndex - The index of this message within the sequence.
      message - An embedded DeadLetterEventEntry containing all information about the message itself.
      enqueuedAt - The time the message was enqueued.
      lastTouched - The time the message has been last processed.
      cause - The reason the message was enqueued.
      diagnostics - The diagnostics, a map of metadata.
      converter - The Converter to use for serializing the diagnostics.
  • Method Details

    • getDeadLetterId

      public String getDeadLetterId()
      The unique ID of this dead letter in the database.
      Returns:
      The unique ID.
    • getProcessingGroup

      public String getProcessingGroup()
      The processing group this dead letter belongs to.
      Returns:
      The processing group.
    • getSequenceIdentifier

      public String getSequenceIdentifier()
      The sequence identifier of this dead letter. If two have the same, they must be handled sequentially.
      Returns:
      The sequence identifier.
    • getSequenceIndex

      public long getSequenceIndex()
      The index of this message within the getSequenceIdentifier(), used for keeping the messages in the same order within the same sequence.
      Returns:
      The index.
    • getMessage

      public DeadLetterEventEntry getMessage()
      The embedded DeadLetterEventEntry representing the original message.
      Returns:
      The embedded original message.
    • getEnqueuedAt

      public Instant getEnqueuedAt()
      The time the message was enqueued.
      Returns:
      The time the message was enqueued.
    • getLastTouched

      public Instant getLastTouched()
      The time the messages was last touched, meaning having been queued or having been tried to process.
      Returns:
      The time the messages was last touched.
    • setLastTouched

      public void setLastTouched(Instant lastTouched)
      Sets the time the message was last touched. Should be updated every time the message has been attempted to process.
      Parameters:
      lastTouched - The new time to set to.
    • getProcessingStarted

      public Instant getProcessingStarted()
      Timestamp indicating when the processing of this dead letter has started. Used for claiming messages and preventing multiple processes or thread from handling items concurrently within the same sequence.
      Returns:
      Timestamp of start processing.
    • getCauseType

      public String getCauseType()
      Gets the class of the original exception.
      Returns:
      The type of the cause.
    • getCauseMessage

      public String getCauseMessage()
      Gets the message of the original exception.
      Returns:
      The message of the cause.
    • getDiagnostics

      public byte[] getDiagnostics()
      Returns the serialized diagnostics as a byte array.
      Returns:
      The serialized diagnostics bytes.
    • setCause

      public void setCause(Cause cause)
      Sets the cause of the error when the message was originally processed, or processed later and the cause was updated.
      Parameters:
      cause - The new cause to set to.
    • setDiagnostics

      public void setDiagnostics(Metadata diagnostics, Converter converter)
      Sets the diagnostics, using the given Converter to serialize to byte array format.
      Parameters:
      diagnostics - The new diagnostics.
      converter - The Converter to use for serialization.
    • clearProcessingStarted

      public void clearProcessingStarted()
      Releases the message for processing by another thread or process.

      Note: This field is set executing sql directly in JpaSequencedDeadLetterQueue when claiming a dead letter.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object