Package org.apache.qpid.protonj2.engine
Interface TransactionManager
- All Superinterfaces:
Endpoint<TransactionManager>
- All Known Implementing Classes:
ProtonTransactionManager
Transaction Manager endpoint that implements the mechanics of handling the declaration
of and the requested discharge of AMQP transactions. Typically an AMQP server instance
will host the transaction management services that are used by client resources to declare
and discharge transaction and handle the associated of deliveries that are enlisted in
active transactions.
-
Method Summary
Modifier and TypeMethodDescriptionaddCredit(int additionalCredit) Adds the given amount of credit for theTransactionManagerwhich allows theTransactionControllerto sendDeclareandDischargerequests to this manager.default TransactionManagerdeclared(Transaction<TransactionManager> transaction, byte[] txnId) Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.declared(Transaction<TransactionManager> transaction, Binary txnId) Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.declareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction declaration has failed and is not active.declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler) Called when theTransactionControllerend of the link has requested a new transaction be declared using the information provided in the givenDeclareinstance.discharged(Transaction<TransactionManager> transaction) Respond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge completed on the transaction identified by given transaction Id has now been retired.dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Respond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge resulted in an error and the transaction must be considered rolled back.dischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler) Called when theTransactionControllerend of the link has requested a current transaction be discharged using the information provided in the givenDischargeinstance.Returns the currently set Coordinator target for thisLink.intGet the credit that is currently available or assigned to thisTransactionManager.Returns the remote targetTerminusfor this transaction manager which must be of typeCoordinatoror null if remote did not set a terminus.Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionManageris locally closed.setCoordinator(Coordinator coordinator) Sets theCoordinatortarget to assign to the local end of thisTransactionManager.Sets theSourceto assign to the local end of thisTransactionManager.Methods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
close, 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 Details
-
addCredit
Adds the given amount of credit for theTransactionManagerwhich allows theTransactionControllerto sendDeclareandDischargerequests to this manager. TheTransactionControllercannot send any requests to start or complete a transaction without having credit to do so which implies that theTransactionManagerowner must grant credit as part of its normal processing.- Parameters:
additionalCredit- the new amount of credits to add.- Returns:
- this
TransactionManager - Throws:
IllegalArgumentException- if the credit amount is negative.
-
getCredit
int getCredit()Get the credit that is currently available or assigned to thisTransactionManager.- Returns:
- the current unused credit.
-
setSource
Sets theSourceto assign to the local end of thisTransactionManager. Must be called during setup, i.e. before calling theEndpoint.open()method.- Parameters:
source- TheSourcethat will be set on the local end of this transaction controller.- Returns:
- this transaction controller instance.
- Throws:
IllegalStateException- if theTransactionManagerhas already been opened.
-
getSource
Source getSource()- Returns:
- the
Sourcefor the local end of thisTransactionController.
-
setCoordinator
Sets theCoordinatortarget to assign to the local end of thisTransactionManager. Must be called during setup, i.e. before calling theEndpoint.open()method.- Parameters:
coordinator- TheCoordinatortarget that will be set on the local end of this transaction controller.- Returns:
- this transaction controller instance.
- Throws:
IllegalStateException- if theTransactionManagerhas already been opened.
-
getCoordinator
Coordinator getCoordinator()Returns the currently set Coordinator target for thisLink.- Returns:
- the link target
Coordinatorfor the local end of this link.
-
getRemoteSource
Source getRemoteSource()- Returns:
- the source
Sourcefor the remote end of thisTransactionManager.
-
getRemoteCoordinator
Coordinator getRemoteCoordinator()Returns the remote targetTerminusfor this transaction manager which must be of typeCoordinatoror null if remote did not set a terminus.- Returns:
- the remote coordinator
Terminusfor the remote end of this link.
-
declared
Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.- Parameters:
transaction- The transaction instance that is associated with the declared transaction.txnId- The binary transaction Id to assign the now declared transaction instance.- Returns:
- this
TransactionManager.
-
declared
Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.- Parameters:
transaction- The transaction instance that is associated with the declared transaction.txnId- The binary transaction Id to assign the now declared transaction instance.- Returns:
- this
TransactionManager.
-
declareFailed
TransactionManager declareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction declaration has failed and is not active.- Parameters:
transaction- The transaction instance that is associated with the declared transaction.condition- TheErrorConditionthat described the reason for the transaction failure.- Returns:
- this
TransactionManager.
-
discharged
Respond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge completed on the transaction identified by given transaction Id has now been retired.- Parameters:
transaction- TheTransactioninstance that has been discharged and is now retired.- Returns:
- this
TransactionManager.
-
dischargeFailed
TransactionManager dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Respond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge resulted in an error and the transaction must be considered rolled back.- Parameters:
transaction- TheTransactioninstance that has been discharged and is now retired.condition- TheErrorConditionthat described the reason for the transaction failure.- Returns:
- this
TransactionManager.
-
declareHandler
TransactionManager declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler) Called when theTransactionControllerend of the link has requested a new transaction be declared using the information provided in the givenDeclareinstance.- Parameters:
declaredEventHandler- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager.
-
dischargeHandler
TransactionManager dischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler) Called when theTransactionControllerend of the link has requested a current transaction be discharged using the information provided in the givenDischargeinstance.- Parameters:
dischargeEventHandler- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager.
-
parentEndpointClosedHandler
Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionManageris 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- TheEventHandlerto notify when this transaction manger's parent endpoint is locally closed.- Returns:
- the link for chaining.
-