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
ConstructorDescriptionProtonTransactionManager
(ProtonReceiver receiverLink) Creates a newTransactionManager
instance that wraps the givenReceiver
link. -
Method Summary
Modifier and TypeMethodDescriptionaddCredit
(int additional) Adds the given amount of credit for theTransactionManager
which allows theTransactionController
to sendDeclare
andDischarge
requests 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 previousDeclare
request from the remoteTransactionController
indicating 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 previousDeclare
request from the remoteTransactionController
indicating that the requested transaction declaration has failed and is not active.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.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.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.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.Returns the currently set Coordinator target for thisLink
.int
Get the credit that is currently available or assigned to thisTransactionManager
.Symbol[]
Symbol[]
Gets the parent of thisEndpoint
which can be itself forConnection
instance.If the remote has closed thisEndpoint
and provided anErrorCondition
as part of the closing AMQP performative then this method will return it.Returns the remote targetTerminus
for this transaction manager which must be of typeCoordinator
or null if remote did not set a terminus.Symbol[]
Symbol[]
boolean
Returns true if thisEndpoint
is currently locally closed meaning that a call to theEndpoint.close()
method has occurred.boolean
Returns true if thisEndpoint
is currently locally open meaning that theEndpoint.open()
has been called but theEndpoint.close()
has not.boolean
boolean
open()
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 aEventHandler
for when the parentSession
orConnection
of thisTransactionManager
is locally closed.setCondition
(ErrorCondition condition) Sets the localErrorCondition
to be applied to aEndpoint
close.setCoordinator
(Coordinator coordinator) Sets theCoordinator
target to assign to the local end of thisTransactionManager
.setDesiredCapabilities
(Symbol... desiredCapabilities) Sets the capabilities that are desired from the remote when thisEndpoint
is opened.setOfferedCapabilities
(Symbol... offeredCapabilities) Sets the capabilities to be offered on to the remote when thisEndpoint
is opened.setProperties
(Map<Symbol, Object> properties) Sets the properties to be sent to the remote when thisEndpoint
is Opened.Sets theSource
to 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 Details
-
ProtonTransactionManager
Creates a newTransactionManager
instance that wraps the givenReceiver
link.- Parameters:
receiverLink
- TheReceiver
link that thisTransactionManager
wraps.
-
-
Method Details
-
getParent
Description copied from interface:Endpoint
Gets the parent of thisEndpoint
which can be itself forConnection
instance.- Specified by:
getParent
in interfaceEndpoint<TransactionManager>
- Returns:
- the parent of this
Endpoint
or itself if this is aConnection
;
-
addCredit
Description copied from interface:TransactionManager
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.- Specified by:
addCredit
in interfaceTransactionManager
- Parameters:
additional
- the new amount of credits to add.- Returns:
- this
TransactionManager
-
getCredit
public int getCredit()Description copied from interface:TransactionManager
Get the credit that is currently available or assigned to thisTransactionManager
.- Specified by:
getCredit
in interfaceTransactionManager
- Returns:
- the current unused credit.
-
declared
Description copied from interface:TransactionManager
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.- Specified by:
declared
in 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:TransactionManager
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.- Specified by:
discharged
in interfaceTransactionManager
- Parameters:
transaction
- TheTransaction
instance that has been discharged and is now retired.- Returns:
- this
TransactionManager
.
-
declareFailed
public TransactionManager declareFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Description copied from interface:TransactionManager
Respond to a previousDeclare
request from the remoteTransactionController
indicating that the requested transaction declaration has failed and is not active.- Specified by:
declareFailed
in interfaceTransactionManager
- 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
.
-
dischargeFailed
public TransactionManager dischargeFailed(Transaction<TransactionManager> transaction, ErrorCondition condition) Description copied from interface:TransactionManager
Respond to a previousDischarge
request from the remoteTransactionController
indicating that the discharge resulted in an error and the transaction must be considered rolled back.- Specified by:
dischargeFailed
in interfaceTransactionManager
- 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
public TransactionManager declareHandler(EventHandler<Transaction<TransactionManager>> declaredEventHandler) Description copied from interface:TransactionManager
Called when theTransactionController
end of the link has requested a new transaction be declared using the information provided in the givenDeclare
instance.- Specified by:
declareHandler
in 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:TransactionManager
Called when theTransactionController
end of the link has requested a current transaction be discharged using the information provided in the givenDischarge
instance.- Specified by:
dischargeHandler
in interfaceTransactionManager
- Parameters:
dischargeEventHandler
- handler that will act on the transaction declaration request.- Returns:
- this
TransactionManager
.
-
parentEndpointClosedHandler
Description copied from interface:TransactionManager
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.- Specified by:
parentEndpointClosedHandler
in interfaceTransactionManager
- Parameters:
handler
- TheEventHandler
to notify when this transaction manger's parent endpoint is locally closed.- Returns:
- the link for chaining.
-
open
Description copied from interface:Endpoint
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. 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:
open
in interfaceEndpoint<TransactionManager>
- Returns:
- this
Endpoint
instance. - Throws:
EngineStateException
- if an error occurs opening the Connection or the Engine is shutdown.IllegalStateException
-
close
Description copied from interface:Endpoint
Close 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 theEndpoint
and clean up any local resources before returning normally.- Specified by:
close
in interfaceEndpoint<TransactionManager>
- Returns:
- this
Endpoint
instance. - 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:Endpoint
Returns true if thisEndpoint
is currently locally open meaning that theEndpoint.open()
has been called but theEndpoint.close()
has not.- Specified by:
isLocallyOpen
in interfaceEndpoint<TransactionManager>
- Returns:
true
if theEndpoint
is locally open.- See Also:
-
isLocallyClosed
public boolean isLocallyClosed()Description copied from interface:Endpoint
Returns true if thisEndpoint
is currently locally closed meaning that a call to theEndpoint.close()
method has occurred.- Specified by:
isLocallyClosed
in interfaceEndpoint<TransactionManager>
- Returns:
true
if theEndpoint
is locally closed.- See Also:
-
setSource
Description copied from interface:TransactionManager
Sets theSource
to assign to the local end of thisTransactionManager
. Must be called during setup, i.e. before calling theEndpoint.open()
method.- Specified by:
setSource
in interfaceTransactionManager
- 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
- Specified by:
getSource
in interfaceTransactionManager
- Returns:
- the
Source
for the local end of thisTransactionController
.
-
setCoordinator
Description copied from interface:TransactionManager
Sets theCoordinator
target to assign to the local end of thisTransactionManager
. Must be called during setup, i.e. before calling theEndpoint.open()
method.- Specified by:
setCoordinator
in interfaceTransactionManager
- 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
Description copied from interface:TransactionManager
Returns the currently set Coordinator target for thisLink
.- Specified by:
getCoordinator
in interfaceTransactionManager
- Returns:
- the link target
Coordinator
for the local end of this link.
-
getCondition
- Specified by:
getCondition
in interfaceEndpoint<TransactionManager>
- Overrides:
getCondition
in classProtonEndpoint<TransactionManager>
- Returns:
- the local
Endpoint
error, or null if there is none
-
setCondition
Description copied from interface:Endpoint
Sets the localErrorCondition
to be applied to aEndpoint
close.- Specified by:
setCondition
in interfaceEndpoint<TransactionManager>
- Overrides:
setCondition
in classProtonEndpoint<TransactionManager>
- Parameters:
condition
- The error condition to convey to the remote peer on close of this end point.- Returns:
- this
Endpoint
instance.
-
getProperties
- Specified by:
getProperties
in interfaceEndpoint<TransactionManager>
- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setProperties
Description copied from interface:Endpoint
Sets the properties to be sent to the remote when thisEndpoint
is Opened. TheEndpoint
properties value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Specified by:
setProperties
in interfaceEndpoint<TransactionManager>
- Parameters:
properties
- The properties that will be sent to the remote when this Connection is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
setOfferedCapabilities
public TransactionManager setOfferedCapabilities(Symbol... offeredCapabilities) throws IllegalStateException Description copied from interface:Endpoint
Sets the capabilities to be offered on to the remote when thisEndpoint
is opened. The offered capabilities value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Specified by:
setOfferedCapabilities
in interfaceEndpoint<TransactionManager>
- Parameters:
offeredCapabilities
- The capabilities to be offered to the remote when theEndpoint
is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
getOfferedCapabilities
- Specified by:
getOfferedCapabilities
in interfaceEndpoint<TransactionManager>
- Returns:
- the configured capabilities that are offered to the remote when the
Endpoint
is opened.
-
setDesiredCapabilities
public TransactionManager setDesiredCapabilities(Symbol... desiredCapabilities) throws IllegalStateException Description copied from interface:Endpoint
Sets the capabilities that are desired from the remote when thisEndpoint
is opened. The desired capabilities value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Specified by:
setDesiredCapabilities
in interfaceEndpoint<TransactionManager>
- Parameters:
desiredCapabilities
- The capabilities desired from the remote when theEndpoint
is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
getDesiredCapabilities
- Specified by:
getDesiredCapabilities
in 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:Endpoint
Returns true if thisEndpoint
is 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:
isRemotelyOpen
in interfaceEndpoint<TransactionManager>
- Returns:
true
if theEndpoint
is remotely open.- See Also:
-
isRemotelyClosed
public boolean isRemotelyClosed()Description copied from interface:Endpoint
Returns true if thisEndpoint
is currently remotely closed meaning that the AMQP performative that completes the close phase of thisEndpoint
's lifetime has arrived.- Specified by:
isRemotelyClosed
in interfaceEndpoint<TransactionManager>
- Returns:
true
if theEndpoint
is remotely closed.- See Also:
-
getRemoteOfferedCapabilities
- Specified by:
getRemoteOfferedCapabilities
in interfaceEndpoint<TransactionManager>
- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint
.
-
getRemoteDesiredCapabilities
- Specified by:
getRemoteDesiredCapabilities
in interfaceEndpoint<TransactionManager>
- Returns:
- the capabilities desired by the remote when it opened its end of the
Endpoint
.
-
getRemoteProperties
- Specified by:
getRemoteProperties
in interfaceEndpoint<TransactionManager>
- Returns:
- the properties sent by the remote when it opened its end of the
Endpoint
.
-
getRemoteCondition
Description copied from interface:Endpoint
If the remote has closed thisEndpoint
and provided anErrorCondition
as part of the closing AMQP performative then this method will return it.- Specified by:
getRemoteCondition
in interfaceEndpoint<TransactionManager>
- Overrides:
getRemoteCondition
in classProtonEndpoint<TransactionManager>
- Returns:
- the remote supplied
ErrorCondition
, or null if there is none.
-
getRemoteSource
- Specified by:
getRemoteSource
in interfaceTransactionManager
- Returns:
- the source
Source
for the remote end of thisTransactionManager
.
-
getRemoteCoordinator
Description copied from interface:TransactionManager
Returns the remote targetTerminus
for this transaction manager which must be of typeCoordinator
or null if remote did not set a terminus.- Specified by:
getRemoteCoordinator
in interfaceTransactionManager
- Returns:
- the remote coordinator
Terminus
for the remote end of this link.
-