Interface CompensatableAction
-
- All Known Implementing Classes:
CompensatableActionImpl
public interface CompensatableAction
Multi-work action which is executed atomically. This is an alternative API to use compensating transactions. If all work was completed successfully compensatable transaction is confirmed, otherwise it is compensated.- Author:
- Gytis Trikleris
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompensatableAction
addWork(CompensatableWork compensatableWork, CompensationHandler compensationHandler)
Add a piece of work to the action with a compensation handler.CompensatableAction
addWork(CompensatableWork compensatableWork, CompensationHandler compensationHandler, ConfirmationHandler confirmationHandler)
Add a piece of work to the action with a compensation and a confirmation handlers.CompensatableAction
addWork(CompensatableWork compensatableWork, ConfirmationHandler confirmationHandler)
Add a piece of work to the action with a confirmation handler.void
execute()
Execute all registered work pieces one by one.
-
-
-
Method Detail
-
addWork
CompensatableAction addWork(CompensatableWork compensatableWork, CompensationHandler compensationHandler)
Add a piece of work to the action with a compensation handler.- Parameters:
compensatableWork
- Work that needs to be executed atomically.compensationHandler
- Handler which needs to be invoked in case of failure to undo the work.- Returns:
- this instance of CompensatableAction.
-
addWork
CompensatableAction addWork(CompensatableWork compensatableWork, ConfirmationHandler confirmationHandler)
Add a piece of work to the action with a confirmation handler.- Parameters:
compensatableWork
- Work that needs to be executed atomically.confirmationHandler
- Handler which needs to be invoked if action is completed successfully.- Returns:
- this instance of CompensatableAction
-
addWork
CompensatableAction addWork(CompensatableWork compensatableWork, CompensationHandler compensationHandler, ConfirmationHandler confirmationHandler)
Add a piece of work to the action with a compensation and a confirmation handlers.- Parameters:
compensatableWork
- Work that needs to be executed atomically.compensationHandler
- Handler which needs to be invoked in case of failure to undo the work.confirmationHandler
- Handler which needs to be invoked if action is completed successfully.- Returns:
- this instance of CompensatableAction
-
execute
void execute() throws EnlistException
Execute all registered work pieces one by one.- Throws:
EnlistException
- Is thrown if action fails to register any handler with the transaction.
-
-