Package org.apache.qpid.protonj2.engine
Interface TransactionController
- 
- All Superinterfaces:
- Endpoint<TransactionController>
 - All Known Implementing Classes:
- ProtonTransactionController
 
 public interface TransactionController extends Endpoint<TransactionController> Transaction Controller link that implements the mechanics of declaring and discharging AMQP transactions. ATransactionControlleris typically used at the client side of an AMQPLinkto createTransactioninstances which the client application will enlist its incoming and outgoing deliveries into.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description TransactionControlleraddCapacityAvailableHandler(EventHandler<TransactionController> handler)Allows the caller to add anEventHandlerthat will be signaled when the underlying link for thisTransactionControllerhas been granted credit which would then allow for transactionDeclaredandDischargecommands to be sent to the remote Transactional Resource.Transaction<TransactionController>declare()Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction.TransactionControllerdeclare(Transaction<TransactionController> transaction)Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction.TransactionControllerdeclaredHandler(EventHandler<Transaction<TransactionController>> declaredEventHandler)Called when theTransactionManagerend of the link has responded to a previousDeclarerequest and the transaction can now be used to enroll deliveries into the active transaction.TransactionControllerdeclareFailureHandler(EventHandler<Transaction<TransactionController>> declareFailureEventHandler)Called when theTransactionManagerend of the link responds to aTransactiondeclaration with anRejectedoutcome indicating that the transaction could not be successfully declared.TransactionControllerdischarge(Transaction<TransactionController> transaction, boolean failed)Request that the remoteTransactionManagerdischarge the given transaction and with the specified failure state (true for failed).TransactionControllerdischargedHandler(EventHandler<Transaction<TransactionController>> dischargedEventHandler)Called when theTransactionManagerend of the link has responded to a previousdischarge(Transaction, boolean)request and the transaction has been retired.TransactionControllerdischargeFailureHandler(EventHandler<Transaction<TransactionController>> dischargeFailureEventHandler)Called when theTransactionManagerend of the link has responded to a previousdischarge(Transaction, boolean)request and the transaction discharge failed for some reason.CoordinatorgetCoordinator()Returns the currently set Coordinator target for thisLink.CoordinatorgetRemoteCoordinator()Returns the remote targetTerminusfor this transaction controller which must be of typeCoordinatoror null if remote did not set a terminus.SourcegetRemoteSource()SourcegetSource()booleanhasCapacity()Returnstrueif theTransactionControllerhas capacity to send or buffer andTransactioncommand toDeclareorDischarge.Transaction<TransactionController>newTransaction()Creates a newTransactioninstances that is returned in theTransactionState.IDLEstate which can be populated with application specific attachments or assigned a linked resource prior to calling theTransactionControllerparentEndpointClosedHandler(EventHandler<TransactionController> handler)Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionControlleris locally closed.TransactionControllersetCoordinator(Coordinator coordinator)Sets theCoordinatortarget to assign to the local end of thisTransactionController.TransactionControllersetSource(Source source)Sets theSourceto assign to the local end of thisTransactionController.java.util.Collection<Transaction<TransactionController>>transactions()Returns a list ofTransactionobjects that are active within thisTransactionControllerwhich have not reached a terminal state meaning they have not been successfully discharged and have not failed in either theDeclarephase or theDischargephase.- 
Methods inherited from interface org.apache.qpid.protonj2.engine.Endpointclose, closeHandler, engineShutdownHandler, getAttachments, getCondition, getDesiredCapabilities, getEngine, getLinkedResource, getLinkedResource, getOfferedCapabilities, getParent, getProperties, getRemoteCondition, getRemoteDesiredCapabilities, getRemoteOfferedCapabilities, getRemoteProperties, isLocallyClosed, isLocallyOpen, isRemotelyClosed, isRemotelyOpen, localCloseHandler, localOpenHandler, open, openHandler, setCondition, setDesiredCapabilities, setLinkedResource, setOfferedCapabilities, setProperties
 
- 
 
- 
- 
- 
Method Detail- 
hasCapacityboolean hasCapacity() Returnstrueif theTransactionControllerhas capacity to send or buffer andTransactioncommand toDeclareorDischarge. If no capacity then a call todeclare()or todischarge(Transaction, boolean)would throw an exception.- Returns:
- true if the controller will allow declaring or discharging a transaction at this time.
 
 - 
setSourceTransactionController setSource(Source source) throws java.lang.IllegalStateException Sets theSourceto assign to the local end of thisTransactionController. Must be called during setup, i.e. before calling theEndpoint.open()method.- Parameters:
- source- The- Sourcethat will be set on the local end of this transaction controller.
- Returns:
- this transaction controller instance.
- Throws:
- java.lang.IllegalStateException- if the- TransactionControllerhas already been opened.
 
 - 
getSourceSource getSource() - Returns:
- the Sourcefor the local end of thisTransactionController.
 
 - 
setCoordinatorTransactionController setCoordinator(Coordinator coordinator) throws java.lang.IllegalStateException Sets theCoordinatortarget to assign to the local end of thisTransactionController. Must be called during setup, i.e. before calling theEndpoint.open()method.- Parameters:
- coordinator- The- Coordinatortarget that will be set on the local end of this transaction controller.
- Returns:
- this transaction controller instance.
- Throws:
- java.lang.IllegalStateException- if the- TransactionControllerhas already been opened.
 
 - 
getCoordinatorCoordinator getCoordinator() Returns the currently set Coordinator target for thisLink.- Returns:
- the link target Coordinatorfor the local end of this link.
 
 - 
getRemoteSourceSource getRemoteSource() - Returns:
- the source Sourcefor the remote end of thisTransactionController.
 
 - 
getRemoteCoordinatorCoordinator getRemoteCoordinator() Returns the remote targetTerminusfor this transaction controller which must be of typeCoordinatoror null if remote did not set a terminus.- Returns:
- the remote coordinator Terminusfor the remote end of this link.
 
 - 
transactionsjava.util.Collection<Transaction<TransactionController>> transactions() Returns a list ofTransactionobjects that are active within thisTransactionControllerwhich have not reached a terminal state meaning they have not been successfully discharged and have not failed in either theDeclarephase or theDischargephase. If there are no transactions active within thisTransactionControllerthis method returns an emptyCollection.- Returns:
- a list of Transactions that are allocated to this controller that have not reached a terminal state.
 
 - 
newTransactionTransaction<TransactionController> newTransaction() Creates a newTransactioninstances that is returned in theTransactionState.IDLEstate which can be populated with application specific attachments or assigned a linked resource prior to calling the- Returns:
- a new Transactioninstance that can be correlated with later declared events.
 
 - 
declareTransaction<TransactionController> declare() Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction. Upon successful declaration of a new transaction the remote will respond and thedeclaredHandler(EventHandler)event handler will be signaled. This is a convenience method that is the same as first callingnewTransaction()and then passing the result of that to thedeclare(Transaction)method.- Returns:
- a new Transactioninstance that can be correlated with later declared events.
 
 - 
declareTransactionController declare(Transaction<TransactionController> transaction) Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction. Upon successful declaration of a new transaction the remote will respond and thedeclaredHandler(EventHandler)event handler will be signaled.- Parameters:
- transaction- The- Transactionthat is will be associated with the eventual declared transaction.
- Returns:
- this TransactionController
 
 - 
dischargeTransactionController discharge(Transaction<TransactionController> transaction, boolean failed) Request that the remoteTransactionManagerdischarge the given transaction and with the specified failure state (true for failed). Upon successful declaration of a new transaction the remote will respond and thedeclaredHandler(EventHandler)event handler will be signaled.- Parameters:
- transaction- The- Transactionthat is being discharged.
- failed- boolean value indicating the the discharge indicates the transaction failed (rolled back).
- Returns:
- this TransactionController
 
 - 
declaredHandlerTransactionController declaredHandler(EventHandler<Transaction<TransactionController>> declaredEventHandler) Called when theTransactionManagerend of the link has responded to a previousDeclarerequest and the transaction can now be used to enroll deliveries into the active transaction.- Parameters:
- declaredEventHandler- An- EventHandlerthat will act on the transaction declaration request.
- Returns:
- this TransactionController.
 
 - 
declareFailureHandlerTransactionController declareFailureHandler(EventHandler<Transaction<TransactionController>> declareFailureEventHandler) Called when theTransactionManagerend of the link responds to aTransactiondeclaration with anRejectedoutcome indicating that the transaction could not be successfully declared.- Parameters:
- declareFailureEventHandler- An- EventHandlerthat will be called when a previous transaction declaration fails.
- Returns:
- this TransactionController.
 
 - 
dischargedHandlerTransactionController dischargedHandler(EventHandler<Transaction<TransactionController>> dischargedEventHandler) Called when theTransactionManagerend of the link has responded to a previousdischarge(Transaction, boolean)request and the transaction has been retired.- Parameters:
- dischargedEventHandler- An- EventHandlerthat will act on the transaction discharge request.
- Returns:
- this TransactionController.
 
 - 
dischargeFailureHandlerTransactionController dischargeFailureHandler(EventHandler<Transaction<TransactionController>> dischargeFailureEventHandler) Called when theTransactionManagerend of the link has responded to a previousdischarge(Transaction, boolean)request and the transaction discharge failed for some reason.- Parameters:
- dischargeFailureEventHandler- An- EventHandlerthat will act on the transaction discharge failed event.
- Returns:
- this TransactionController.
 
 - 
addCapacityAvailableHandlerTransactionController addCapacityAvailableHandler(EventHandler<TransactionController> handler) Allows the caller to add anEventHandlerthat will be signaled when the underlying link for thisTransactionControllerhas been granted credit which would then allow for transactionDeclaredandDischargecommands to be sent to the remote Transactional Resource. If the controller already has credit to send then the handler will be invoked immediately otherwise it will be stored until credit becomes available. Once a handler is signaled it is no longer retained for future updates and the caller will need to register it again once more transactional work is to be completed. Because more than one handler can be added at a time the caller should check again before attempting to perform a transactionDeclaredorDischargeis performed as other tasks might have already consumed credit if work is done via some asynchronous mechanism.- Parameters:
- handler- The- EventHandlerthat will be signaled once credit is available for transaction work.
- Returns:
- this TransactionControllerinstance.
 
 - 
parentEndpointClosedHandlerTransactionController parentEndpointClosedHandler(EventHandler<TransactionController> handler) Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionControlleris locally closed. Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.- Parameters:
- handler- The- EventHandlerto notify when this transaction controller's parent endpoint is locally closed.
- Returns:
- the link for chaining.
 
 
- 
 
-