Interface DeadLetter<M extends Message>
- Type Parameters:
M- The type ofMessagerepresented 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
or
invalid reference
SequencedDeadLetterQueue#requeue(DeadLetter, UnaryOperator)
, is kept in invalid reference
processinglastTouched(). 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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncause()default Contextcontext()Returns theContextassociated with this dead letter, carrying resources that were present in theProcessingContextwhen the letter was enqueued.The diagnosticMetadataconcerning this letter.The moment in time when themessage()was entered in a dead letter queue.static Optional<DeadLetter<?>> fromContext(Context context) Returns anOptionalof {DeadLetter}, returning the resource keyed under theRESOURCE_KEYin the givencontext.The moment in time when this letter was last touched.Construct a copy of thisDeadLetter, replacing thelastTouched()with the current time.message()TheMessageof typeMcontained in this letter.default DeadLetter<M> withDiagnostics(UnaryOperator<Metadata> diagnosticsBuilder) Construct a copy of thisDeadLetter, replacing thediagnostics()with the result of the givendiagnosticsBuilder.withDiagnostics(Metadata diagnostics)
-
Field Details
-
RESOURCE_KEY
-
-
Method Details
-
fromContext
Returns anOptionalof {DeadLetter}, returning the resource keyed under theRESOURCE_KEYin the givencontext.- Parameters:
context- theContextto retrieve theDeadLetterfrom, if present- Returns:
- an
Optionalof {DeadLetter}, returning the resource keyed under theRESOURCE_KEYin the givencontext
-
message
M message()TheMessageof typeMcontained in this letter.- Returns:
- The
Messageof typeMcontained in this letter.
-
cause
Thecausefor themessage()to be dead lettered. Can be anOptional.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. -
enqueuedAt
Instant enqueuedAt()The moment in time when themessage()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 theenqueuedAt()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 diagnosticMetadataconcerning this letter.- Returns:
- The diagnostic
Metadataconcerning this letter.
-
markTouched
DeadLetter<M> markTouched()Construct a copy of thisDeadLetter, replacing thelastTouched()with the current time.- Returns:
- A copy of this
DeadLetterwithlastTouched()set to now.
-
withCause
- Parameters:
requeueCause- The new cause of theDeadLetterunder construction.- Returns:
- A copy of this
DeadLetter, replacing thecause()with the givenrequeueCause.
-
withDiagnostics
- Parameters:
diagnostics- The diagnosticMetadatato append to theDeadLetterunder construction.- Returns:
- A copy of this
DeadLetter, replacing thediagnostics()with the givendiagnostics.
-
withDiagnostics
Construct a copy of thisDeadLetter, replacing thediagnostics()with the result of the givendiagnosticsBuilder. ThediagnosticsBuilderwill be invoked with the diagnostics of this instance.- Parameters:
diagnosticsBuilder- Thelambdaconstructing diagnosticMetadatato replace theMetadataof theDeadLetterunder construction.- Returns:
- A copy of this
DeadLetter, replacing thediagnostics()with the result of the givendiagnosticsBuilder.
-
context
Returns theContextassociated with this dead letter, carrying resources that were present in theProcessingContextwhen the letter was enqueued. Defaults toContext.empty()if not overridden.The following resources are stored and restored through this context:
TrackingToken.RESOURCE_KEY— always present when the letter was enqueued by a streaming event processor.LegacyResources.AGGREGATE_TYPE_KEY,LegacyResources.AGGREGATE_IDENTIFIER_KEY, andLegacyResources.AGGREGATE_SEQUENCE_NUMBER_KEY— present only when the event was stored by an aggregate-based event storage engine.
- Returns:
- The
Contextassociated with this dead letter.
-