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 toDeclare
and toDischarge
AMQPTransaction
instance.
-
-
Field Summary
-
Fields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine
-
-
Constructor Summary
Constructors Constructor Description ProtonTransactionManager(ProtonReceiver receiverLink)
Creates a newTransactionManager
instance that wraps the givenReceiver
link.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransactionManager
addCredit(int additional)
Adds the given amount of credit for theTransactionManager
which allows theTransactionController
to sendDeclare
andDischarge
requests to this manager.TransactionManager
close()
Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.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.ErrorCondition
getCondition()
Coordinator
getCoordinator()
Returns the currently set Coordinator target for thisLink
.int
getCredit()
Get the credit that is currently available or assigned to thisTransactionManager
.Symbol[]
getDesiredCapabilities()
Symbol[]
getOfferedCapabilities()
ProtonSession
getParent()
Gets the parent of thisEndpoint
which can be itself forConnection
instance.java.util.Map<Symbol,java.lang.Object>
getProperties()
ErrorCondition
getRemoteCondition()
If the remote has closed thisEndpoint
and provided anErrorCondition
as part of the closing AMQP performative then this method will return it.Coordinator
getRemoteCoordinator()
Returns the remote targetTerminus
for this transaction manager which must be of typeCoordinator
or null if remote did not set a terminus.Symbol[]
getRemoteDesiredCapabilities()
Symbol[]
getRemoteOfferedCapabilities()
java.util.Map<Symbol,java.lang.Object>
getRemoteProperties()
Source
getRemoteSource()
Source
getSource()
boolean
isLocallyClosed()
Returns true if thisEndpoint
is currently locally closed meaning that a call to theEndpoint.close()
method has occurred.boolean
isLocallyOpen()
Returns true if thisEndpoint
is currently locally open meaning that theEndpoint.open()
has been called but theEndpoint.close()
has not.boolean
isRemotelyClosed()
boolean
isRemotelyOpen()
TransactionManager
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.TransactionManager
parentEndpointClosedHandler(EventHandler<TransactionManager> handler)
Sets aEventHandler
for when the parentSession
orConnection
of thisTransactionManager
is locally closed.TransactionManager
setCondition(ErrorCondition condition)
Sets the localErrorCondition
to be applied to aEndpoint
close.TransactionManager
setCoordinator(Coordinator coordinator)
Sets theCoordinator
target to assign to the local end of thisTransactionManager
.TransactionManager
setDesiredCapabilities(Symbol... desiredCapabilities)
Sets the capabilities that are desired from the remote when thisEndpoint
is opened.TransactionManager
setOfferedCapabilities(Symbol... offeredCapabilities)
Sets the capabilities to be offered on to the remote when thisEndpoint
is opened.TransactionManager
setProperties(java.util.Map<Symbol,java.lang.Object> properties)
Sets the properties to be sent to the remote when thisEndpoint
is Opened.TransactionManager
setSource(Source source)
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 Detail
-
ProtonTransactionManager
public ProtonTransactionManager(ProtonReceiver receiverLink)
Creates a newTransactionManager
instance that wraps the givenReceiver
link.- Parameters:
receiverLink
- TheReceiver
link that thisTransactionManager
wraps.
-
-
Method Detail
-
getParent
public ProtonSession 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
public TransactionManager addCredit(int additional)
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
public TransactionManager declared(Transaction<TransactionManager> transaction, Binary txnId)
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
public TransactionManager discharged(Transaction<TransactionManager> transaction)
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
public TransactionManager parentEndpointClosedHandler(EventHandler<TransactionManager> handler)
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
public TransactionManager open() throws java.lang.IllegalStateException, EngineStateException
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.java.lang.IllegalStateException
-
close
public TransactionManager close() throws EngineFailedException
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:
Endpoint.isLocallyClosed()
-
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:
Endpoint.isLocallyOpen()
-
setSource
public TransactionManager setSource(Source source) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException
- if theTransactionManager
has already been opened.
-
getSource
public Source getSource()
- Specified by:
getSource
in interfaceTransactionManager
- Returns:
- the
Source
for the local end of thisTransactionController
.
-
setCoordinator
public TransactionManager setCoordinator(Coordinator coordinator) throws java.lang.IllegalStateException
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:
java.lang.IllegalStateException
- if theTransactionManager
has already been opened.
-
getCoordinator
public Coordinator 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
public ErrorCondition getCondition()
- Specified by:
getCondition
in interfaceEndpoint<TransactionManager>
- Overrides:
getCondition
in classProtonEndpoint<TransactionManager>
- Returns:
- the local
Endpoint
error, or null if there is none
-
setCondition
public TransactionManager setCondition(ErrorCondition condition)
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
public java.util.Map<Symbol,java.lang.Object> getProperties()
- Specified by:
getProperties
in 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: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:
java.lang.IllegalStateException
- if theEndpoint
has already been opened.
-
setOfferedCapabilities
public TransactionManager setOfferedCapabilities(Symbol... offeredCapabilities) throws java.lang.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:
java.lang.IllegalStateException
- if theEndpoint
has already been opened.
-
getOfferedCapabilities
public Symbol[] 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 java.lang.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:
java.lang.IllegalStateException
- if theEndpoint
has already been opened.
-
getDesiredCapabilities
public Symbol[] 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:
Endpoint.isRemotelyClosed()
-
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:
Endpoint.isRemotelyOpen()
-
getRemoteOfferedCapabilities
public Symbol[] getRemoteOfferedCapabilities()
- Specified by:
getRemoteOfferedCapabilities
in interfaceEndpoint<TransactionManager>
- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint
.
-
getRemoteDesiredCapabilities
public Symbol[] getRemoteDesiredCapabilities()
- Specified by:
getRemoteDesiredCapabilities
in 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:
getRemoteProperties
in 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: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
public Source getRemoteSource()
- Specified by:
getRemoteSource
in interfaceTransactionManager
- Returns:
- the source
Source
for the remote end of thisTransactionManager
.
-
getRemoteCoordinator
public Coordinator 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.
-
-