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
TransactionManagerimplementation that implements the abstraction around a receiver link that responds to requests toDeclareand toDischargeAMQPTransactioninstance.
-
-
Field Summary
-
Fields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine
-
-
Constructor Summary
Constructors Constructor Description ProtonTransactionManager(ProtonReceiver receiverLink)Creates a newTransactionManagerinstance that wraps the givenReceiverlink.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransactionManageraddCredit(int additional)Adds the given amount of credit for theTransactionManagerwhich allows theTransactionControllerto sendDeclareandDischargerequests to this manager.TransactionManagerclose()Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.TransactionManagerdeclared(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.TransactionManagerdeclareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition)Respond to a previousDeclarerequest from the remoteTransactionControllerindicating that the requested transaction declaration has failed and is not active.TransactionManagerdeclareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler)Called when theTransactionControllerend of the link has requested a new transaction be declared using the information provided in the givenDeclareinstance.TransactionManagerdischarged(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.TransactionManagerdischargeFailed(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.TransactionManagerdischargeHandler(EventHandler<Transaction<TransactionManager>> dischargeEventHandler)Called when theTransactionControllerend of the link has requested a current transaction be discharged using the information provided in the givenDischargeinstance.ErrorConditiongetCondition()CoordinatorgetCoordinator()Returns the currently set Coordinator target for thisLink.intgetCredit()Get the credit that is currently available or assigned to thisTransactionManager.Symbol[]getDesiredCapabilities()Symbol[]getOfferedCapabilities()ProtonSessiongetParent()Gets the parent of thisEndpointwhich can be itself forConnectioninstance.java.util.Map<Symbol,java.lang.Object>getProperties()ErrorConditiongetRemoteCondition()If the remote has closed thisEndpointand provided anErrorConditionas part of the closing AMQP performative then this method will return it.CoordinatorgetRemoteCoordinator()Returns the remote targetTerminusfor this transaction manager which must be of typeCoordinatoror null if remote did not set a terminus.Symbol[]getRemoteDesiredCapabilities()Symbol[]getRemoteOfferedCapabilities()java.util.Map<Symbol,java.lang.Object>getRemoteProperties()SourcegetRemoteSource()SourcegetSource()booleanisLocallyClosed()Returns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.booleanisLocallyOpen()Returns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.booleanisRemotelyClosed()booleanisRemotelyOpen()TransactionManageropen()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.TransactionManagerparentEndpointClosedHandler(EventHandler<TransactionManager> handler)Sets aEventHandlerfor when the parentSessionorConnectionof thisTransactionManageris locally closed.TransactionManagersetCondition(ErrorCondition condition)Sets the localErrorConditionto be applied to aEndpointclose.TransactionManagersetCoordinator(Coordinator coordinator)Sets theCoordinatortarget to assign to the local end of thisTransactionManager.TransactionManagersetDesiredCapabilities(Symbol... desiredCapabilities)Sets the capabilities that are desired from the remote when thisEndpointis opened.TransactionManagersetOfferedCapabilities(Symbol... offeredCapabilities)Sets the capabilities to be offered on to the remote when thisEndpointis opened.TransactionManagersetProperties(java.util.Map<Symbol,java.lang.Object> properties)Sets the properties to be sent to the remote when thisEndpointis Opened.TransactionManagersetSource(Source source)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, setLinkedResource
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
closeHandler, engineShutdownHandler, getAttachments, getEngine, getLinkedResource, getLinkedResource, localCloseHandler, localOpenHandler, openHandler, setLinkedResource
-
Methods inherited from interface org.apache.qpid.protonj2.engine.TransactionManager
declared
-
-
-
-
Constructor Detail
-
ProtonTransactionManager
public ProtonTransactionManager(ProtonReceiver receiverLink)
Creates a newTransactionManagerinstance that wraps the givenReceiverlink.- Parameters:
receiverLink- TheReceiverlink that thisTransactionManagerwraps.
-
-
Method Detail
-
getParent
public ProtonSession 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
public TransactionManager addCredit(int additional)
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
public TransactionManager declared(Transaction<TransactionManager> transaction, Binary txnId)
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
public TransactionManager discharged(Transaction<TransactionManager> transaction)
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
public TransactionManager parentEndpointClosedHandler(EventHandler<TransactionManager> handler)
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
public TransactionManager open() throws java.lang.IllegalStateException, EngineStateException
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.java.lang.IllegalStateException
-
close
public TransactionManager close() throws EngineFailedException
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:
Endpoint.isLocallyClosed()
-
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:
Endpoint.isLocallyOpen()
-
setSource
public TransactionManager setSource(Source source) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException- if theTransactionManagerhas already been opened.
-
getSource
public Source getSource()
- Specified by:
getSourcein interfaceTransactionManager- Returns:
- the
Sourcefor the local end of thisTransactionController.
-
setCoordinator
public TransactionManager setCoordinator(Coordinator coordinator) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException- if theTransactionManagerhas already been opened.
-
getCoordinator
public Coordinator 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
public ErrorCondition getCondition()
- Specified by:
getConditionin interfaceEndpoint<TransactionManager>- Overrides:
getConditionin classProtonEndpoint<TransactionManager>- Returns:
- the local
Endpointerror, or null if there is none
-
setCondition
public TransactionManager setCondition(ErrorCondition condition)
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
public java.util.Map<Symbol,java.lang.Object> getProperties()
- Specified by:
getPropertiesin interfaceEndpoint<TransactionManager>- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setProperties
public TransactionManager setProperties(java.util.Map<Symbol,java.lang.Object> properties) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException- if theEndpointhas already been opened.
-
setOfferedCapabilities
public TransactionManager setOfferedCapabilities(Symbol... offeredCapabilities) throws java.lang.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:
java.lang.IllegalStateException- if theEndpointhas already been opened.
-
getOfferedCapabilities
public Symbol[] 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 java.lang.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:
java.lang.IllegalStateException- if theEndpointhas already been opened.
-
getDesiredCapabilities
public Symbol[] 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:
Endpoint.isRemotelyClosed()
-
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:
Endpoint.isRemotelyOpen()
-
getRemoteOfferedCapabilities
public Symbol[] getRemoteOfferedCapabilities()
- Specified by:
getRemoteOfferedCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint.
-
getRemoteDesiredCapabilities
public Symbol[] getRemoteDesiredCapabilities()
- Specified by:
getRemoteDesiredCapabilitiesin interfaceEndpoint<TransactionManager>- Returns:
- the capabilities desired by the remote when it opened its end of the
Endpoint.
-
getRemoteProperties
public java.util.Map<Symbol,java.lang.Object> getRemoteProperties()
- Specified by:
getRemotePropertiesin interfaceEndpoint<TransactionManager>- Returns:
- the properties sent by the remote when it opened its end of the
Endpoint.
-
getRemoteCondition
public ErrorCondition 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
public Source getRemoteSource()
- Specified by:
getRemoteSourcein interfaceTransactionManager- Returns:
- the source
Sourcefor the remote end of thisTransactionManager.
-
getRemoteCoordinator
public Coordinator 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.
-
-