Interface DeadLetterStatementFactory<E extends EventMessage>
- Type Parameters:
E- An implementation ofEventMessagewithin theDeadLetterthis factory constructsPreparedStatementsfor.
- All Known Implementing Classes:
DefaultDeadLetterStatementFactory
PreparedStatements a JdbcSequencedDeadLetterQueue
requires to function.- Since:
- 4.8.0
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionamountOfSequencesStatement(Connection connection, String processingGroup) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#amountOfSequences()claimableSequencesStatement(Connection connection, String processingGroup, Instant processingStartedLimit, int offset, int maxSize) Constructs thePreparedStatementused to retrieve the identifiers of the first entries of each sequence with that can be claimed.claimStatement(Connection connection, String identifier, Instant current, Instant processingStartedLimit) Constructs thePreparedStatementused to claim aDeadLetterentry.clearStatement(Connection connection, String processingGroup) Constructs thePreparedStatementused for theoperation.invalid reference
clearcontainsStatement(Connection connection, String processingGroup, String sequenceIdentifier) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#contains(Object)enqueueStatement(Connection connection, String processingGroup, String sequenceIdentifier, DeadLetter<? extends E> letter, long sequenceIndex) Constructs thePreparedStatementused for theJdbcSequencedDeadLetterQueue.enqueue(Object, DeadLetter, ProcessingContext)operation.evictStatement(Connection connection, String identifier) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#evict(DeadLetter)letterSequenceStatement(Connection connection, String processingGroup, String sequenceIdentifier, int offset, int maxSize) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#deadLetterSequence(Object)maxIndexStatement(Connection connection, String processingGroup, String sequenceIdentifier) Constructs thePreparedStatementused to retrieve the maximumindexof the sequence identified with the givensequenceIdentifier.nextLetterInSequenceStatement(Connection connection, String processingGroup, String sequenceIdentifier, long sequenceIndex) Constructs thePreparedStatementused to retrieve the followingDeadLetterfrom the sequence identified with the givensequenceIdentifier.requeueStatement(Connection connection, String identifier, Cause cause, Instant lastTouched, Metadata diagnostics) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#requeue(DeadLetter, UnaryOperator)sequenceIdentifiersStatement(Connection connection, String processingGroup) Constructs thePreparedStatementused to iterate over all sequences contained in the queue for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#deadLetters()sequenceSizeStatement(Connection connection, String processingGroup, String sequenceIdentifier) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#sequenceSize(Object)sizeStatement(Connection connection, String processingGroup) Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#size()
-
Method Details
-
enqueueStatement
PreparedStatement enqueueStatement(Connection connection, String processingGroup, String sequenceIdentifier, DeadLetter<? extends E> letter, long sequenceIndex) throws SQLException Constructs thePreparedStatementused for theJdbcSequencedDeadLetterQueue.enqueue(Object, DeadLetter, ProcessingContext)operation.Context resources (e.g., tracking token, aggregate data) are read from
DeadLetter.context().- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to enqueue the givenletter.sequenceIdentifier- The identifier of the sequence the letter belongs to.letter- The letter to enqueue.sequenceIndex- The index of the letter within the sequence, to ensure the processing order is maintained.- Returns:
- The
PreparedStatementused toenqueue. - Throws:
SQLException- When the statement could not be created.
-
maxIndexStatement
PreparedStatement maxIndexStatement(Connection connection, String processingGroup, String sequenceIdentifier) throws SQLException Constructs thePreparedStatementused to retrieve the maximumindexof the sequence identified with the givensequenceIdentifier.Used by the
to deduce the index of theinvalid reference
JdbcSequencedDeadLetterQueue#enqueue(Object, DeadLetter)DeadLetterin its sequence.- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve the maximumindexof the sequence identified through the givensequenceIdentifier.sequenceIdentifier- The identifier of the sequence for which to retrieve the maximumindexfor.- Returns:
- The
PreparedStatementused to retrieve the maximumindexwith. - Throws:
SQLException- When the statement could not be created.
-
evictStatement
Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#evict(DeadLetter)- Parameters:
connection- TheConnectionused to create thePreparedStatement.identifier- The identifier of theDeadLetterto evict.- Returns:
- The
PreparedStatementused to.invalid reference
evict - Throws:
SQLException- When the statement could not be created.
-
requeueStatement
PreparedStatement requeueStatement(Connection connection, String identifier, Cause cause, Instant lastTouched, Metadata diagnostics) throws SQLException Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#requeue(DeadLetter, UnaryOperator)- Parameters:
connection- TheConnectionused to create thePreparedStatement.identifier- The identifier of theDeadLetterto requeue.cause- The cause of requeueing theDeadLetteridentified through the givenidentifier.lastTouched- TheInstanttheDeadLetterto requeue was last processed.diagnostics- The new diagnostics to attach to theDeadLetterto requeue.- Returns:
- The
PreparedStatementused to.invalid reference
requeue - Throws:
SQLException- When the statement could not be created.
-
containsStatement
PreparedStatement containsStatement(Connection connection, String processingGroup, String sequenceIdentifier) throws SQLException Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#contains(Object)- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to check whether the sequence identified by the givensequenceIdentifier.sequenceIdentifier- The identifier of the sequence to validate whether it is contained in the queue.- Returns:
- The
PreparedStatementused to check whether the givensequenceIdentifierisin the queue.invalid reference
contained - Throws:
SQLException- When the statement could not be created.
-
letterSequenceStatement
PreparedStatement letterSequenceStatement(Connection connection, String processingGroup, String sequenceIdentifier, int offset, int maxSize) throws SQLException Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#deadLetterSequence(Object)As dead-letter sequences can be large, the
JdbcSequencedDeadLetterQueueassumes it needs to page through the result set. To that end it is recommended to use the givenoffsetto define the starting point of the query (for example by validate theDeadLetterSchema.sequenceIndexColumn()). The givenmaxSizecan be used to limit the result.- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve a dead-letter sequence.sequenceIdentifier- The identifier of the sequence to retrieve.offset- The offset from where to start thePreparedStatementunder construction.maxSize- The maximum size to limit thePreparedStatementunder construction.- Returns:
- The
PreparedStatementused to return the dead letter sequence for the givensequenceIdentifierwith. - Throws:
SQLException- When the statement could not be created.
-
sequenceIdentifiersStatement
PreparedStatement sequenceIdentifiersStatement(Connection connection, String processingGroup) throws SQLException Constructs thePreparedStatementused to iterate over all sequences contained in the queue for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#deadLetters()- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve all sequence identifiers.- Returns:
- The
PreparedStatementused to return all sequence identifiers enqueued in the givenprocessingGroupwith. - Throws:
SQLException- When the statement could not be created.
-
sizeStatement
Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#size()- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve the size for.- Returns:
- The
PreparedStatementused to retrieve the size with. - Throws:
SQLException- When the statement could not be created.
-
sequenceSizeStatement
PreparedStatement sequenceSizeStatement(Connection connection, String processingGroup, String sequenceIdentifier) throws SQLException Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#sequenceSize(Object)- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve the size of the identified sequence.sequenceIdentifier- The identifier of the sequence for which to retrieve the size.- Returns:
- The
PreparedStatementused to retrieve the size of the sequence identified by the givensequenceIdentifierwith. - Throws:
SQLException- When the statement could not be created.
-
amountOfSequencesStatement
PreparedStatement amountOfSequencesStatement(Connection connection, String processingGroup) throws SQLException Constructs thePreparedStatementused for theoperation.invalid reference
JdbcSequencedDeadLetterQueue#amountOfSequences()- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to retrieve the amount of sequences.- Returns:
- The
PreparedStatementused to retrieve the amount of sequences with. - Throws:
SQLException- When the statement could not be created.
-
claimableSequencesStatement
PreparedStatement claimableSequencesStatement(Connection connection, String processingGroup, Instant processingStartedLimit, int offset, int maxSize) throws SQLException Constructs thePreparedStatementused to retrieve the identifiers of the first entries of each sequence with that can be claimed.Used by the
andinvalid reference
JdbcSequencedDeadLetterQueue#process(Function)operations. A row may be claimed if theinvalid reference
JdbcSequencedDeadLetterQueue#process(Predicate, Function)processing startedfield is older than the givenprocessingStartedLimit.The amount of sequences in a queue can be vast, hence the
JdbcSequencedDeadLetterQueueassumes it needs to page through the result set. To that end it is recommended to use the givenoffsetto define the starting point of the query (for example by validate theDeadLetterSchema.sequenceIndexColumn()). The givenmaxSizecan be used to limit the result.- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group to find claimable sequences for.processingStartedLimit- TheInstantused to compare with theprocessing startedfield.offset- The offset from where to start thePreparedStatementunder construction.maxSize- The maximum size to limit thePreparedStatementunder construction.- Returns:
- The
PreparedStatementused to find the identifier of the first entries of each sequence that are claimable. - Throws:
SQLException- When the statement could not be created.
-
claimStatement
PreparedStatement claimStatement(Connection connection, String identifier, Instant current, Instant processingStartedLimit) throws SQLException Constructs thePreparedStatementused to claim aDeadLetterentry.Claiming a
DeadLetterensures only a single threadtheinvalid reference
processesDeadLetter. This operation typically update theprocessing startedfield with the givencurrentInstant, marking it as claimed for a certain timeframe.The returned statement is used after the
JdbcSequencedDeadLetterQueuesearched forclaimable sequencesduring aorinvalid reference
JdbcSequencedDeadLetterQueue#process(Function)invocation.invalid reference
JdbcSequencedDeadLetterQueue#process(Predicate, Function)- Parameters:
connection- TheConnectionused to create thePreparedStatement.identifier- The identifier of theDeadLetterto claim.current- TheInstantused to update theprocessing startedfield with to mark it as claimed.processingStartedLimit- TheInstantused to compare with theprocessing startedfield, to ensure it wasn't claimed by another process.- Returns:
- The
PreparedStatementused to claim aDeadLetterwith for, ensuring no two threads are processing the same letter.invalid reference
processing - Throws:
SQLException- When the statement could not be created.
-
nextLetterInSequenceStatement
PreparedStatement nextLetterInSequenceStatement(Connection connection, String processingGroup, String sequenceIdentifier, long sequenceIndex) throws SQLException Constructs thePreparedStatementused to retrieve the followingDeadLetterfrom the sequence identified with the givensequenceIdentifier. The returned statement is used after theThe returned statement is used after the
JdbcSequencedDeadLetterQueueclaimeda letter and successfully processed it during aorinvalid reference
JdbcSequencedDeadLetterQueue#process(Function)invocation.invalid reference
JdbcSequencedDeadLetterQueue#process(Predicate, Function)- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to return the followingDeadLetterin the sequence identified by the givensequenceIdentifier.sequenceIdentifier- The identifier of the sequence for which to retrieve the followingDeadLetterfor.sequenceIndex- The index of the letter preceding the followingDeadLetterto retrieve.- Returns:
- The
PreparedStatementused to retrieve theDeadLetterin the sequence identified by the givensequenceIdentifierwith. - Throws:
SQLException- When the statement could not be created.
-
clearStatement
Constructs thePreparedStatementused for theoperation.invalid reference
clearWill only remove all entries for the given
processingGroup.- Parameters:
connection- TheConnectionused to create thePreparedStatement.processingGroup- The processing group for which to clear all entries.- Returns:
- The
PreparedStatementused toall entries for the giveninvalid reference
clearprocessingGroupwith. - Throws:
SQLException- When the statement could not be created.
-