Package org.apache.qpid.protonj2.engine
Interface TransactionManager
-
- All Superinterfaces:
Endpoint<TransactionManager>
- All Known Implementing Classes:
ProtonTransactionManager
public interface TransactionManager extends Endpoint<TransactionManager>
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description TransactionManager
addCredit(int additionalCredit)
Adds the given amount of credit for theTransactionManager
which allows theTransactionController
to sendDeclare
andDischarge
requests to this manager.default TransactionManager
declared(Transaction<TransactionManager> transaction, byte[] txnId)
Respond to a previousDeclare
request from the remoteTransactionController
indicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.TransactionManager
declared(Transaction<TransactionManager> transaction, Binary txnId)
Respond to a previousDeclare
request from the remoteTransactionController
indicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.TransactionManager
declareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition)
Respond to a previousDeclare
request from the remoteTransactionController
indicating that the requested transaction declaration has failed and is not active.TransactionManager
declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler)
Called when theTransactionController
end of the link has requested a new transaction be declared using the information provided in the givenDeclare
instance.TransactionManager
discharged(Transaction<TransactionManager> transaction)
Respond to a previousDischarge
request from the remoteTransactionController
indicating that the discharge completed on the transaction identified by given transaction Id has now been retired.TransactionManager
dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition)
Respond to a previousDischarge
request from the remoteTransactionController
indicating that the discharge resulted in an error and the transaction must be considered rolled back.TransactionManager
dischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler)
Called when theTransactionController
end of the link has requested a current transaction be discharged using the information provided in the givenDischarge
instance.Coordinator
getCoordinator()
Returns the currently set Coordinator target for thisLink
.int
getCredit()
Get the credit that is currently available or assigned to thisTransactionManager
.Coordinator
getRemoteCoordinator()
Returns the remote targetTerminus
for this transaction manager which must be of typeCoordinator
or null if remote did not set a terminus.Source
getRemoteSource()
Source
getSource()
TransactionManager
parentEndpointClosedHandler(EventHandler<TransactionManager> handler)
Sets aEventHandler
for when the parentSession
orConnection
of thisTransactionManager
is locally closed.TransactionManager
setCoordinator(Coordinator coordinator)
Sets theCoordinator
target to assign to the local end of thisTransactionManager
.TransactionManager
setSource(Source source)
Sets theSource
to 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 Detail
-
addCredit
TransactionManager addCredit(int additionalCredit)
Adds the given amount of credit for theTransactionManager
which allows theTransactionController
to sendDeclare
andDischarge
requests to this manager. TheTransactionController
cannot send any requests to start or complete a transaction without having credit to do so which implies that theTransactionManager
owner 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
TransactionManager setSource(Source source) throws IllegalStateException
Sets theSource
to assign to the local end of thisTransactionManager
. Must be called during setup, i.e. before calling theEndpoint.open()
method.- Parameters:
source
- TheSource
that will be set on the local end of this transaction controller.- Returns:
- this transaction controller instance.
- Throws:
IllegalStateException
- if theTransactionManager
has already been opened.
-
getSource
Source getSource()
- Returns:
- the
Source
for the local end of thisTransactionController
.
-
setCoordinator
TransactionManager setCoordinator(Coordinator coordinator) throws IllegalStateException
Sets theCoordinator
target to assign to the local end of thisTransactionManager
. Must be called during setup, i.e. before calling theEndpoint.open()
method.- Parameters:
coordinator
- TheCoordinator
target that will be set on the local end of this transaction controller.- Returns:
- this transaction controller instance.
- Throws:
IllegalStateException
- if theTransactionManager
has already been opened.
-
getCoordinator
Coordinator getCoordinator()
Returns the currently set Coordinator target for thisLink
.- Returns:
- the link target
Coordinator
for the local end of this link.
-
getRemoteSource
Source getRemoteSource()
- Returns:
- the source
Source
for the remote end of thisTransactionManager
.
-
getRemoteCoordinator
Coordinator getRemoteCoordinator()
Returns the remote targetTerminus
for this transaction manager which must be of typeCoordinator
or null if remote did not set a terminus.- Returns:
- the remote coordinator
Terminus
for the remote end of this link.
-
declared
default TransactionManager declared(Transaction<TransactionManager> transaction, byte[] txnId)
Respond to a previousDeclare
request from the remoteTransactionController
indicating 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
TransactionManager declared(Transaction<TransactionManager> transaction, Binary txnId)
Respond to a previousDeclare
request from the remoteTransactionController
indicating 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 previousDeclare
request from the remoteTransactionController
indicating that the requested transaction declaration has failed and is not active.- Parameters:
transaction
- The transaction instance that is associated with the declared transaction.condition
- TheErrorCondition
that described the reason for the transaction failure.- Returns:
- this
TransactionManager
.
-
discharged
TransactionManager discharged(Transaction<TransactionManager> transaction)
Respond to a previousDischarge
request from the remoteTransactionController
indicating that the discharge completed on the transaction identified by given transaction Id has now been retired.- Parameters:
transaction
- TheTransaction
instance that has been discharged and is now retired.- Returns:
- this
TransactionManager
.
-
dischargeFailed
TransactionManager dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition)
Respond to a previousDischarge
request from the remoteTransactionController
indicating that the discharge resulted in an error and the transaction must be considered rolled back.- Parameters:
transaction
- TheTransaction
instance that has been discharged and is now retired.condition
- TheErrorCondition
that described the reason for the transaction failure.- Returns:
- this
TransactionManager
.
-
declareHandler
TransactionManager declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler)
Called when theTransactionController
end of the link has requested a new transaction be declared using the information provided in the givenDeclare
instance.- Parameters:
declaredEventHandler
- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager
.
-
dischargeHandler
TransactionManager dischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler)
Called when theTransactionController
end of the link has requested a current transaction be discharged using the information provided in the givenDischarge
instance.- Parameters:
dischargeEventHandler
- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager
.
-
parentEndpointClosedHandler
TransactionManager parentEndpointClosedHandler(EventHandler<TransactionManager> handler)
Sets aEventHandler
for when the parentSession
orConnection
of thisTransactionManager
is 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
- TheEventHandler
to notify when this transaction manger's parent endpoint is locally closed.- Returns:
- the link for chaining.
-
-