Class ProtonTransactionManager
java.lang.Object
org.apache.qpid.protonj2.engine.impl.ProtonEndpoint<TransactionManager>
org.apache.qpid.protonj2.engine.impl.ProtonTransactionManager
- All Implemented Interfaces:
Endpoint<TransactionManager>,TransactionManager
public final class ProtonTransactionManager
extends ProtonEndpoint<TransactionManager>
implements TransactionManager
TransactionManager implementation that implements the abstraction
around a receiver link that responds to requests to Declare and to
Discharge AMQP Transaction instance.-
Field Summary
Fields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine -
Constructor Summary
ConstructorsConstructorDescriptionProtonTransactionManager(ProtonReceiver receiverLink) Creates a newTransactionManagerinstance that wraps the givenReceiverlink. -
Method Summary
Modifier and TypeMethodDescriptionaddCredit(int additional) Adds the given amount of credit for theTransactionManagerwhich allows theTransactionControllerto sendDeclareandDischargerequests to this manager.close()Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.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.Symbol[]Symbol[]Gets the parent of thisEndpointwhich can be itself forConnectioninstance.If the remote has closed thisEndpointand provided anErrorConditionas part of the closing AMQP performative then this method will return it.Returns the remote targetTerminusfor this transaction manager which must be of typeCoordinatoror null if remote did not set a terminus.Symbol[]Symbol[]booleanReturns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.booleanReturns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.booleanbooleanopen()Open the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed.Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionManageris locally closed.setCondition(ErrorCondition condition) Sets the localErrorConditionto be applied to aEndpointclose.setCoordinator(Coordinator coordinator) Sets theCoordinatortarget to assign to the local end of thisTransactionManager.setDesiredCapabilities(Symbol... desiredCapabilities) Sets the capabilities that are desired from the remote when thisEndpointis opened.setOfferedCapabilities(Symbol... offeredCapabilities) Sets the capabilities to be offered on to the remote when thisEndpointis opened.setProperties(Map<Symbol, Object> properties) Sets the properties to be sent to the remote when thisEndpointis Opened.Sets theSourceto assign to the local end of thisTransactionManager.Methods inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
closeHandler, engineShutdownHandler, getAttachments, getEngine, getLinkedResource, getLinkedResource, localCloseHandler, localOpenHandler, openHandler, setLinkedResourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
closeHandler, engineShutdownHandler, getAttachments, getEngine, getLinkedResource, getLinkedResource, localCloseHandler, localOpenHandler, openHandler, setLinkedResourceMethods inherited from interface org.apache.qpid.protonj2.engine.TransactionManager
declared
-
Constructor Details
-
ProtonTransactionManager
Creates a newTransactionManagerinstance that wraps the givenReceiverlink.- Parameters:
receiverLink- TheReceiverlink that thisTransactionManagerwraps.
-
-
Method Details
-
getParent
Description copied from interface:EndpointGets the parent of thisEndpointwhich can be itself forConnectioninstance.- Specified by:
getParentin interfaceEndpoint<TransactionManager>- Returns:
- the parent of this
Endpointor itself if this is aConnection;
-
addCredit
Description copied from interface:TransactionManagerAdds 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.- Specified by:
addCreditin interfaceTransactionManager- Parameters:
additional- the new amount of credits to add.- Returns:
- this
TransactionManager
-
getCredit
public int getCredit()Description copied from interface:TransactionManagerGet the credit that is currently available or assigned to thisTransactionManager.- Specified by:
getCreditin interfaceTransactionManager- Returns:
- the current unused credit.
-
declared
Description copied from interface:TransactionManagerRespond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction has been successfully declared and that deliveries can now be enlisted in that transaction.- Specified by:
declaredin interfaceTransactionManager- 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.
-
discharged
Description copied from interface:TransactionManagerRespond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge completed on the transaction identified by given transaction Id has now been retired.- Specified by:
dischargedin interfaceTransactionManager- Parameters:
transaction- TheTransactioninstance that has been discharged and is now retired.- Returns:
- this
TransactionManager.
-
declareFailed
public TransactionManager declareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Description copied from interface:TransactionManagerRespond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction declaration has failed and is not active.- Specified by:
declareFailedin interfaceTransactionManager- Parameters:
transaction- The transaction instance that is associated with the declared transaction.condition- TheErrorConditionthat described the reason for the transaction failure.- Returns:
- this
TransactionManager.
-
dischargeFailed
public TransactionManager dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Description copied from interface:TransactionManagerRespond to a previousDischargerequest from the remoteTransactionControllerindicating that the discharge resulted in an error and the transaction must be considered rolled back.- Specified by:
dischargeFailedin interfaceTransactionManager- Parameters:
transaction- TheTransactioninstance that has been discharged and is now retired.condition- TheErrorConditionthat described the reason for the transaction failure.- Returns:
- this
TransactionManager.
-
declareHandler
public TransactionManager declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler) Description copied from interface:TransactionManagerCalled when theTransactionControllerend of the link has requested a new transaction be declared using the information provided in the givenDeclareinstance.- Specified by:
declareHandlerin interfaceTransactionManager- Parameters:
declaredEventHandler- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager.
-
dischargeHandler
public TransactionManager dischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler) Description copied from interface:TransactionManagerCalled when theTransactionControllerend of the link has requested a current transaction be discharged using the information provided in the givenDischargeinstance.- Specified by:
dischargeHandlerin interfaceTransactionManager- Parameters:
dischargeEventHandler- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager.
-
parentEndpointClosedHandler
Description copied from interface:TransactionManagerSets 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.- Specified by:
parentEndpointClosedHandlerin interfaceTransactionManager- Parameters:
handler- TheEventHandlerto notify when this transaction manger's parent endpoint is locally closed.- Returns:
- the link for chaining.
-
open
Description copied from interface:EndpointOpen the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives.- Specified by:
openin interfaceEndpoint<TransactionManager>- Returns:
- this
Endpointinstance. - Throws:
EngineStateException- if an error occurs opening the Connection or the Engine is shutdown.IllegalStateException
-
close
Description copied from interface:EndpointClose the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it. If the engine encounters an error writing the performative or the engine is in a failed state from a previous error then this method will throw an exception. If the engine has been shutdown then this method will close out the local end of theEndpointand clean up any local resources before returning normally.- Specified by:
closein interfaceEndpoint<TransactionManager>- Returns:
- this
Endpointinstance. - Throws:
EngineFailedException- if an error occurs closing the end point or the Engine is in a failed state.
-
isLocallyOpen
public boolean isLocallyOpen()Description copied from interface:EndpointReturns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.- Specified by:
isLocallyOpenin interfaceEndpoint<TransactionManager>- Returns:
trueif theEndpointis locally open.- See Also:
-
isLocallyClosed
public boolean isLocallyClosed()Description copied from interface:EndpointReturns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.- Specified by:
isLocallyClosedin interfaceEndpoint<TransactionManager>- Returns:
trueif theEndpointis locally closed.- See Also:
-
setSource
Description copied from interface:TransactionManagerSets theSourceto assign to the local end of thisTransactionManager. Must be called during setup, i.e. before calling theEndpoint.open()method.- Specified by:
setSourcein interfaceTransactionManager- 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
- Specified by:
getSourcein interfaceTransactionManager- Returns:
- the
Sourcefor the local end of thisTransactionController.
-
setCoordinator
Description copied from interface:TransactionManagerSets theCoordinatortarget to assign to the local end of thisTransactionManager. Must be called during setup, i.e. before calling theEndpoint.open()method.- Specified by:
setCoordinatorin interfaceTransactionManager- 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
Description copied from interface:TransactionManagerReturns the currently set Coordinator target for thisLink.- Specified by:
getCoordinatorin interfaceTransactionManager- Returns:
- the link target
Coordinatorfor the local end of this link.
-
getCondition
- Specified by:
getConditionin interfaceEndpoint<TransactionManager>- Overrides:
getConditionin classProtonEndpoint<TransactionManager>- Returns:
- the local
Endpointerror, or null if there is none
-
setCondition
Description copied from interface:EndpointSets the localErrorConditionto be applied to aEndpointclose.- Specified by:
setConditionin interfaceEndpoint<TransactionManager>- Overrides:
setConditionin classProtonEndpoint<TransactionManager>- Parameters:
condition- The error condition to convey to the remote peer on close of this end point.- Returns:
- this
Endpointinstance.
-
getProperties
- Specified by:
getPropertiesin interfaceEndpoint<TransactionManager>- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setProperties
Description copied from interface:EndpointSets the properties to be sent to the remote when thisEndpointis Opened. TheEndpointproperties value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setPropertiesin interfaceEndpoint<TransactionManager>- Parameters:
properties- The properties that will be sent to the remote when this Connection is opened.- Returns:
- this
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas already been opened.
-
setOfferedCapabilities
public TransactionManager setOfferedCapabilities(Symbol... offeredCapabilities) throws IllegalStateException Description copied from interface:EndpointSets the capabilities to be offered on to the remote when thisEndpointis opened. The offered capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setOfferedCapabilitiesin interfaceEndpoint<TransactionManager>- Parameters:
offeredCapabilities- The capabilities to be offered to the remote when theEndpointis opened.- Returns:
- this
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas already been opened.
-
getOfferedCapabilities
- Specified by:
getOfferedCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the configured capabilities that are offered to the remote when the
Endpointis opened.
-
setDesiredCapabilities
public TransactionManager setDesiredCapabilities(Symbol... desiredCapabilities) throws IllegalStateException Description copied from interface:EndpointSets the capabilities that are desired from the remote when thisEndpointis opened. The desired capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Specified by:
setDesiredCapabilitiesin interfaceEndpoint<TransactionManager>- Parameters:
desiredCapabilities- The capabilities desired from the remote when theEndpointis opened.- Returns:
- this
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas already been opened.
-
getDesiredCapabilities
- Specified by:
getDesiredCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
-
isRemotelyOpen
public boolean isRemotelyOpen()Description copied from interface:EndpointReturns true if thisEndpointis currently remotely open meaning that the AMQP performative that completes the open phase of thisEndpoint's lifetime has arrived but the performative that closes it has not.- Specified by:
isRemotelyOpenin interfaceEndpoint<TransactionManager>- Returns:
trueif theEndpointis remotely open.- See Also:
-
isRemotelyClosed
public boolean isRemotelyClosed()Description copied from interface:EndpointReturns true if thisEndpointis currently remotely closed meaning that the AMQP performative that completes the close phase of thisEndpoint's lifetime has arrived.- Specified by:
isRemotelyClosedin interfaceEndpoint<TransactionManager>- Returns:
trueif theEndpointis remotely closed.- See Also:
-
getRemoteOfferedCapabilities
- Specified by:
getRemoteOfferedCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint.
-
getRemoteDesiredCapabilities
- Specified by:
getRemoteDesiredCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the capabilities desired by the remote when it opened its end of the
Endpoint.
-
getRemoteProperties
- Specified by:
getRemotePropertiesin interfaceEndpoint<TransactionManager>- Returns:
- the properties sent by the remote when it opened its end of the
Endpoint.
-
getRemoteCondition
Description copied from interface:EndpointIf the remote has closed thisEndpointand provided anErrorConditionas part of the closing AMQP performative then this method will return it.- Specified by:
getRemoteConditionin interfaceEndpoint<TransactionManager>- Overrides:
getRemoteConditionin classProtonEndpoint<TransactionManager>- Returns:
- the remote supplied
ErrorCondition, or null if there is none.
-
getRemoteSource
- Specified by:
getRemoteSourcein interfaceTransactionManager- Returns:
- the source
Sourcefor the remote end of thisTransactionManager.
-
getRemoteCoordinator
Description copied from interface:TransactionManagerReturns the remote targetTerminusfor this transaction manager which must be of typeCoordinatoror null if remote did not set a terminus.- Specified by:
getRemoteCoordinatorin interfaceTransactionManager- Returns:
- the remote coordinator
Terminusfor the remote end of this link.
-