Package com.gruelbox.transactionoutbox
Interface TransactionOutboxListener
-
public interface TransactionOutboxListener
A listener for events fired byTransactionOutbox
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
TransactionOutboxListener.Invocator
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default TransactionOutboxListener
andThen(TransactionOutboxListener other)
Chains this listener with another and returns the result.default void
blocked(TransactionOutboxEntry entry, Throwable cause)
Fired when a transaction outbox task has passed the maximum number of retries and has been blocked.default void
failure(TransactionOutboxEntry entry, Throwable cause)
Fired when a transaction outbox task fails.default void
scheduled(TransactionOutboxEntry entry)
Fired when a transaction outbox task is scheduled.default void
success(TransactionOutboxEntry entry)
Fired when a transaction outbox task is successfully completed and recorded as such in the database such that it will not be re-attempted.default void
wrapInvocation(TransactionOutboxListener.Invocator invocator)
Implement this method to intercept and decorate all outbox invocations.
-
-
-
Method Detail
-
scheduled
default void scheduled(TransactionOutboxEntry entry)
Fired when a transaction outbox task is scheduled.This event is not guaranteed to fire in the event of a JVM failure or power loss. It is fired after the commit to the database adding the scheduled task but before the task is submitted for processing. It will, except in extreme circumstances (although this is not guaranteed), fire prior to any subsequent
success(TransactionOutboxEntry)
orfailure(TransactionOutboxEntry, Throwable)
.- Parameters:
entry
- The outbox entry scheduled.
-
wrapInvocation
default void wrapInvocation(TransactionOutboxListener.Invocator invocator) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
Implement this method to intercept and decorate all outbox invocations. In general, you should callinvocation.run()
which actually calls the underlying method, unless you are deliberately trying to suppress the method call.- Parameters:
invocator
- A runnable which performs the work of the scheduled task.- Throws:
IllegalAccessException
- If thrown by the method invocation.IllegalArgumentException
- If thrown by the method invocation.InvocationTargetException
- If thrown by the method invocation.
-
success
default void success(TransactionOutboxEntry entry)
Fired when a transaction outbox task is successfully completed and recorded as such in the database such that it will not be re-attempted. Note that:TransactionOutbox
uses "at least once" semantics, so the actual processing of a task may complete any number of times before this event is fired.- This event is not guaranteed to fire in the event of a JVM failure or power loss. It is fired after the commit to the database removing the completed task and all bets are off after this point.
- Parameters:
entry
- The outbox entry completed.
-
failure
default void failure(TransactionOutboxEntry entry, Throwable cause)
Fired when a transaction outbox task fails. This may occur multiple times until the maximum number of retries, at which point this will be fired and thenblocked(TransactionOutboxEntry, Throwable)
. This event is not guaranteed to fire in the event of a JVM failure or power loss. It is fired after the commit to the database marking the task as failed.- Parameters:
entry
- The outbox entry failed.cause
- The cause of the most recent failure.
-
blocked
default void blocked(TransactionOutboxEntry entry, Throwable cause)
Fired when a transaction outbox task has passed the maximum number of retries and has been blocked. This event is not guaranteed to fire in the event of a JVM failure or power loss. It is fired after the commit to the database marking the task as blocked.- Parameters:
entry
- The outbox entry to be marked as blocked.cause
- The cause of the most recent failure.
-
andThen
default TransactionOutboxListener andThen(TransactionOutboxListener other)
Chains this listener with another and returns the result.- Parameters:
other
- The other listener. It will always be called after this one.- Returns:
- The combined listener.
-
-