Class ProtonTransactionController
java.lang.Object
org.apache.qpid.protonj2.engine.impl.ProtonEndpoint<TransactionController>
org.apache.qpid.protonj2.engine.impl.ProtonTransactionController
- All Implemented Interfaces:
- Endpoint<TransactionController>,- TransactionController
public class ProtonTransactionController
extends ProtonEndpoint<TransactionController>
implements TransactionController
TransactionController implementation that implements the abstraction
 around a sender link that initiates requests to Declare and to
 Discharge AMQP Transaction instance.- 
Field SummaryFields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpointengine
- 
Constructor SummaryConstructorsConstructorDescriptionProtonTransactionController(ProtonSender senderLink) Creates a newTransactionControllerinstance that wraps the givenSenderlink.
- 
Method SummaryModifier and TypeMethodDescriptionAllows 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.close()Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.declare()Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction.declare(Transaction<TransactionController> transaction) Request that the remoteTransactionManagerdeclare a new transaction and respond with a new transaction Id for that transaction.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.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.discharge(Transaction<TransactionController> transaction, boolean failed) Request that the remoteTransactionManagerdischarge the given transaction and with the specified failure state (true for failed).dischargedHandler(EventHandler<Transaction<TransactionController>> dischargedEventHandler) Called when theTransactionManagerend of the link has responded to a previousTransactionController.discharge(Transaction, boolean)request and the transaction has been retired.dischargeFailureHandler(EventHandler<Transaction<TransactionController>> dischargeFailureEventHandler) Called when theTransactionManagerend of the link has responded to a previousTransactionController.discharge(Transaction, boolean)request and the transaction discharge failed for some reason.Returns the currently set Coordinator target for thisLink.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 controller which must be of typeCoordinatoror null if remote did not set a terminus.Symbol[]Symbol[]booleanReturnstrueif theTransactionControllerhas capacity to send or buffer andTransactioncommand toDeclareorDischarge.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.booleanbooleanorg.apache.qpid.protonj2.engine.impl.ProtonTransactionController.ProtonControllerTransactionCreates a newTransactioninstances that is returned in theTransactionState.IDLEstate which can be populated with application specific attachments or assigned a linked resource prior to calling theopen()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 thisTransactionControlleris locally closed.setCondition(ErrorCondition condition) Sets the localErrorConditionto be applied to aEndpointclose.setCoordinator(Coordinator coordinator) Sets theCoordinatortarget to assign to the local end of thisTransactionController.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 thisTransactionController.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 class org.apache.qpid.protonj2.engine.impl.ProtonEndpointcloseHandler, engineShutdownHandler, getAttachments, getEngine, getLinkedResource, getLinkedResource, localCloseHandler, localOpenHandler, openHandler, setLinkedResourceMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.qpid.protonj2.engine.EndpointcloseHandler, engineShutdownHandler, getAttachments, getEngine, getLinkedResource, getLinkedResource, localCloseHandler, localOpenHandler, openHandler, setLinkedResource
- 
Constructor Details- 
ProtonTransactionControllerCreates a newTransactionControllerinstance that wraps the givenSenderlink.- Parameters:
- senderLink- The- Senderthat this- TransactionControllerwraps.
 
 
- 
- 
Method Details- 
getParentDescription copied from interface:EndpointGets the parent of thisEndpointwhich can be itself forConnectioninstance.- Specified by:
- getParentin interface- Endpoint<TransactionController>
- Returns:
- the parent of this Endpointor itself if this is aConnection;
 
- 
hasCapacitypublic boolean hasCapacity()Description copied from interface:TransactionControllerReturnstrueif theTransactionControllerhas capacity to send or buffer andTransactioncommand toDeclareorDischarge. If no capacity then a call toTransactionController.declare()or toTransactionController.discharge(Transaction, boolean)would throw an exception.- Specified by:
- hasCapacityin interface- TransactionController
- Returns:
- true if the controller will allow declaring or discharging a transaction at this time.
 
- 
addCapacityAvailableHandlerpublic ProtonTransactionController addCapacityAvailableHandler(EventHandler<TransactionController> handler) Description copied from interface:TransactionControllerAllows 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.- Specified by:
- addCapacityAvailableHandlerin interface- TransactionController
- Parameters:
- handler- The- EventHandlerthat will be signaled once credit is available for transaction work.
- Returns:
- this TransactionControllerinstance.
 
- 
transactionsDescription copied from interface:TransactionControllerReturns 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.- Specified by:
- transactionsin interface- TransactionController
- Returns:
- a list of Transactions that are allocated to this controller that have not reached a terminal state.
 
- 
newTransactionpublic org.apache.qpid.protonj2.engine.impl.ProtonTransactionController.ProtonControllerTransaction newTransaction()Description copied from interface:TransactionControllerCreates 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- Specified by:
- newTransactionin interface- TransactionController
- Returns:
- a new Transactioninstance that can be correlated with later declared events.
 
- 
declareDescription copied from interface:TransactionControllerRequest 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 theTransactionController.declaredHandler(EventHandler)event handler will be signaled. This is a convenience method that is the same as first callingTransactionController.newTransaction()and then passing the result of that to theTransactionController.declare(Transaction)method.- Specified by:
- declarein interface- TransactionController
- Returns:
- a new Transactioninstance that can be correlated with later declared events.
 
- 
declareDescription copied from interface:TransactionControllerRequest 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 theTransactionController.declaredHandler(EventHandler)event handler will be signaled.- Specified by:
- declarein interface- TransactionController
- Parameters:
- transaction- The- Transactionthat is will be associated with the eventual declared transaction.
- Returns:
- this TransactionController
 
- 
dischargepublic TransactionController discharge(Transaction<TransactionController> transaction, boolean failed) Description copied from interface:TransactionControllerRequest 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 theTransactionController.declaredHandler(EventHandler)event handler will be signaled.- Specified by:
- dischargein interface- TransactionController
- Parameters:
- transaction- The- Transactionthat is being discharged.
- failed- boolean value indicating the the discharge indicates the transaction failed (rolled back).
- Returns:
- this TransactionController
 
- 
declaredHandlerpublic TransactionController declaredHandler(EventHandler<Transaction<TransactionController>> declaredEventHandler) Description copied from interface:TransactionControllerCalled when theTransactionManagerend of the link has responded to a previousDeclarerequest and the transaction can now be used to enroll deliveries into the active transaction.- Specified by:
- declaredHandlerin interface- TransactionController
- Parameters:
- declaredEventHandler- An- EventHandlerthat will act on the transaction declaration request.
- Returns:
- this TransactionController.
 
- 
declareFailureHandlerpublic TransactionController declareFailureHandler(EventHandler<Transaction<TransactionController>> declareFailureEventHandler) Description copied from interface:TransactionControllerCalled when theTransactionManagerend of the link responds to aTransactiondeclaration with anRejectedoutcome indicating that the transaction could not be successfully declared.- Specified by:
- declareFailureHandlerin interface- TransactionController
- Parameters:
- declareFailureEventHandler- An- EventHandlerthat will be called when a previous transaction declaration fails.
- Returns:
- this TransactionController.
 
- 
dischargedHandlerpublic TransactionController dischargedHandler(EventHandler<Transaction<TransactionController>> dischargedEventHandler) Description copied from interface:TransactionControllerCalled when theTransactionManagerend of the link has responded to a previousTransactionController.discharge(Transaction, boolean)request and the transaction has been retired.- Specified by:
- dischargedHandlerin interface- TransactionController
- Parameters:
- dischargedEventHandler- An- EventHandlerthat will act on the transaction discharge request.
- Returns:
- this TransactionController.
 
- 
dischargeFailureHandlerpublic TransactionController dischargeFailureHandler(EventHandler<Transaction<TransactionController>> dischargeFailureEventHandler) Description copied from interface:TransactionControllerCalled when theTransactionManagerend of the link has responded to a previousTransactionController.discharge(Transaction, boolean)request and the transaction discharge failed for some reason.- Specified by:
- dischargeFailureHandlerin interface- TransactionController
- Parameters:
- dischargeFailureEventHandler- An- EventHandlerthat will act on the transaction discharge failed event.
- Returns:
- this TransactionController.
 
- 
parentEndpointClosedHandlerpublic TransactionController parentEndpointClosedHandler(EventHandler<TransactionController> handler) Description copied from interface:TransactionControllerSets 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.- Specified by:
- parentEndpointClosedHandlerin interface- TransactionController
- Parameters:
- handler- The- EventHandlerto notify when this transaction controller's parent endpoint is locally closed.
- Returns:
- the link for chaining.
 
- 
openDescription 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 interface- Endpoint<TransactionController>
- Returns:
- this Endpointinstance.
- Throws:
- EngineStateException- if an error occurs opening the Connection or the Engine is shutdown.
- IllegalStateException
 
- 
closeDescription 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 interface- Endpoint<TransactionController>
- Returns:
- this Endpointinstance.
- Throws:
- EngineFailedException- if an error occurs closing the end point or the Engine is in a failed state.
 
- 
isLocallyOpenpublic 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 interface- Endpoint<TransactionController>
- Returns:
- trueif the- Endpointis locally open.
- See Also:
 
- 
isLocallyClosedpublic 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 interface- Endpoint<TransactionController>
- Returns:
- trueif the- Endpointis locally closed.
- See Also:
 
- 
setSourceDescription copied from interface:TransactionControllerSets theSourceto assign to the local end of thisTransactionController. Must be called during setup, i.e. before calling theEndpoint.open()method.- Specified by:
- setSourcein interface- TransactionController
- Parameters:
- source- The- Sourcethat will be set on the local end of this transaction controller.
- Returns:
- this transaction controller instance.
- Throws:
- IllegalStateException- if the- TransactionControllerhas already been opened.
 
- 
getSource- Specified by:
- getSourcein interface- TransactionController
- Returns:
- the Sourcefor the local end of thisTransactionController.
 
- 
setCoordinatorDescription copied from interface:TransactionControllerSets theCoordinatortarget to assign to the local end of thisTransactionController. Must be called during setup, i.e. before calling theEndpoint.open()method.- Specified by:
- setCoordinatorin interface- TransactionController
- Parameters:
- coordinator- The- Coordinatortarget that will be set on the local end of this transaction controller.
- Returns:
- this transaction controller instance.
- Throws:
- IllegalStateException- if the- TransactionControllerhas already been opened.
 
- 
getCoordinatorDescription copied from interface:TransactionControllerReturns the currently set Coordinator target for thisLink.- Specified by:
- getCoordinatorin interface- TransactionController
- Returns:
- the link target Coordinatorfor the local end of this link.
 
- 
getCondition- Specified by:
- getConditionin interface- Endpoint<TransactionController>
- Overrides:
- getConditionin class- ProtonEndpoint<TransactionController>
- Returns:
- the local Endpointerror, or null if there is none
 
- 
setConditionDescription copied from interface:EndpointSets the localErrorConditionto be applied to aEndpointclose.- Specified by:
- setConditionin interface- Endpoint<TransactionController>
- Overrides:
- setConditionin class- ProtonEndpoint<TransactionController>
- Parameters:
- condition- The error condition to convey to the remote peer on close of this end point.
- Returns:
- this Endpointinstance.
 
- 
getProperties- Specified by:
- getPropertiesin interface- Endpoint<TransactionController>
- Returns:
- the configured properties sent to the remote when this Connection is opened.
 
- 
setPropertiespublic TransactionController setProperties(Map<Symbol, Object> properties) throws IllegalStateExceptionDescription 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 interface- Endpoint<TransactionController>
- Parameters:
- properties- The properties that will be sent to the remote when this Connection is opened.
- Returns:
- this Endpointinstance.
- Throws:
- IllegalStateException- if the- Endpointhas already been opened.
 
- 
setOfferedCapabilitiespublic TransactionController 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 interface- Endpoint<TransactionController>
- Parameters:
- offeredCapabilities- The capabilities to be offered to the remote when the- Endpointis opened.
- Returns:
- this Endpointinstance.
- Throws:
- IllegalStateException- if the- Endpointhas already been opened.
 
- 
getOfferedCapabilities- Specified by:
- getOfferedCapabilitiesin interface- Endpoint<TransactionController>
- Returns:
- the configured capabilities that are offered to the remote when the Endpointis opened.
 
- 
setDesiredCapabilitiespublic TransactionController 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 interface- Endpoint<TransactionController>
- Parameters:
- desiredCapabilities- The capabilities desired from the remote when the- Endpointis opened.
- Returns:
- this Endpointinstance.
- Throws:
- IllegalStateException- if the- Endpointhas already been opened.
 
- 
getDesiredCapabilities- Specified by:
- getDesiredCapabilitiesin interface- Endpoint<TransactionController>
- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
 
- 
isRemotelyOpenpublic 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 interface- Endpoint<TransactionController>
- Returns:
- trueif the- Endpointis remotely open.
- See Also:
 
- 
isRemotelyClosedpublic 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 interface- Endpoint<TransactionController>
- Returns:
- trueif the- Endpointis remotely closed.
- See Also:
 
- 
getRemoteOfferedCapabilities- Specified by:
- getRemoteOfferedCapabilitiesin interface- Endpoint<TransactionController>
- Returns:
- the capabilities offered by the remote when it opened its end of the Endpoint.
 
- 
getRemoteDesiredCapabilities- Specified by:
- getRemoteDesiredCapabilitiesin interface- Endpoint<TransactionController>
- Returns:
- the capabilities desired by the remote when it opened its end of the Endpoint.
 
- 
getRemoteProperties- Specified by:
- getRemotePropertiesin interface- Endpoint<TransactionController>
- Returns:
- the properties sent by the remote when it opened its end of the Endpoint.
 
- 
getRemoteConditionDescription 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 interface- Endpoint<TransactionController>
- Overrides:
- getRemoteConditionin class- ProtonEndpoint<TransactionController>
- Returns:
- the remote supplied ErrorCondition, or null if there is none.
 
- 
getRemoteSource- Specified by:
- getRemoteSourcein interface- TransactionController
- Returns:
- the source Sourcefor the remote end of thisTransactionController.
 
- 
getRemoteCoordinatorDescription copied from interface:TransactionControllerReturns the remote targetTerminusfor this transaction controller which must be of typeCoordinatoror null if remote did not set a terminus.- Specified by:
- getRemoteCoordinatorin interface- TransactionController
- Returns:
- the remote coordinator Terminusfor the remote end of this link.
 
 
-