-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature : Blocked entries methods #338
Open
RomainWilbert
wants to merge
9
commits into
gruelbox:master
Choose a base branch
from
RomainWilbert:feat-blocked-entries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9ebd669
feat: add unblockAll and getBlockedEntries methods
9285697
fix: codefactor
1b4bca8
fix: format
f8697b7
fix: javadoc
80b7fe9
fix: .gitignore
388dc51
Update DefaultPersistor.java
RomainWilbert bbc1e71
fix: uncomment unit test
RomainWilbert ce96bf3
fix: getBlockedEntries shall not process entries
RomainWilbert f30145b
Merge branch 'gruelbox:master' into feat-blocked-entries
RomainWilbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
**/.classpath | ||
**/.project | ||
**/.settings | ||
**/.factorypath | ||
/.idea | ||
/*.iml | ||
**/target/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.time.Clock; | ||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.concurrent.Executor; | ||
import java.util.function.Supplier; | ||
import lombok.ToString; | ||
|
@@ -38,8 +39,9 @@ static TransactionOutboxBuilder builder() { | |
* | ||
* <p>Usage: | ||
* | ||
* <pre>transactionOutbox.schedule(MyService.class) | ||
* .runMyMethod("with", "some", "arguments");</pre> | ||
* <pre> | ||
* transactionOutbox.schedule(MyService.class).runMyMethod("with", "some", "arguments"); | ||
* </pre> | ||
* | ||
* <p>This will write a record to the database using the supplied {@link Persistor} and {@link | ||
* Instantiator}, using the current database transaction, which will get rolled back if the rest | ||
|
@@ -112,6 +114,26 @@ static TransactionOutboxBuilder builder() { | |
@SuppressWarnings({"unchecked", "rawtypes"}) | ||
boolean unblock(String entryId, Object transactionContext); | ||
|
||
/** | ||
* Unblocks all blocked entries and resets the attempt count so that they will be retried again. | ||
* Requires an active transaction and a transaction manager that supports thread local context. | ||
* | ||
* @return unblocked entries count. | ||
*/ | ||
int unblockAll(); | ||
|
||
/** | ||
* Clears failed entries of their failed state and resets the attempt count so that they will be | ||
* retried again. Requires an active transaction and a transaction manager that supports supplied | ||
* context. | ||
* | ||
* @param transactionContext The transaction context ({@link TransactionManager} implementation | ||
* specific). | ||
* @return unblocked entries count. | ||
*/ | ||
@SuppressWarnings({"unchecked", "rawtypes"}) | ||
int unblockAll(Object transactionContext); | ||
|
||
/** | ||
* Processes an entry immediately in the current thread. Intended for use in custom | ||
* implementations of {@link Submitter} and should not generally otherwise be called. | ||
|
@@ -121,22 +143,43 @@ static TransactionOutboxBuilder builder() { | |
@SuppressWarnings("WeakerAccess") | ||
void processNow(TransactionOutboxEntry entry); | ||
|
||
/** | ||
* Get blocked entries with pagination. | ||
* | ||
* @param page page number | ||
* @param batchSize The number of records to select. | ||
* @return blocked entries | ||
*/ | ||
List<TransactionOutboxEntry> getBlockedEntries(int page, int batchSize); | ||
|
||
/** Builder for {@link TransactionOutbox}. */ | ||
@ToString | ||
abstract class TransactionOutboxBuilder { | ||
|
||
protected TransactionManager transactionManager; | ||
|
||
protected Instantiator instantiator; | ||
|
||
protected Submitter submitter; | ||
|
||
protected Duration attemptFrequency; | ||
|
||
protected int blockAfterAttempts; | ||
|
||
protected int flushBatchSize; | ||
|
||
protected Supplier<Clock> clockProvider; | ||
|
||
protected TransactionOutboxListener listener; | ||
|
||
protected Persistor persistor; | ||
|
||
protected Level logLevelTemporaryFailure; | ||
|
||
protected Boolean serializeMdc; | ||
|
||
protected Duration retentionThreshold; | ||
|
||
protected Boolean initializeImmediately; | ||
|
||
protected TransactionOutboxBuilder() {} | ||
|
@@ -316,10 +359,9 @@ interface ParameterizedScheduleBuilder { | |
* | ||
* <p>Usage example: | ||
* | ||
* <pre>transactionOutbox.with() | ||
* .uniqueRequestId("my-request") | ||
* .schedule(MyService.class) | ||
* .runMyMethod("with", "some", "arguments");</pre> | ||
* <pre> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lost formatting here |
||
* transactionOutbox.with().uniqueRequestId("my-request").schedule(MyService.class).runMyMethod("with", "some", "arguments"); | ||
* </pre> | ||
* | ||
* @param clazz The class to proxy. | ||
* @param <T> The type to proxy. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to handle different dialects (
LIMIT
isn't supported by Oracle).Sorry @RomainWilbert; I got around to re-checking this PR after the Oracle PR was merged.