Interface ClientTransactionContext
-
public interface ClientTransactionContext
Base for a Transaction Context used inClientSession
instances to mask from the senders and receivers the work of deciding transaction specific behaviors.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClientTransactionContext
begin(ClientFuture<Session> beginFuture)
Begin a new transaction if one is not already in play.ClientTransactionContext
commit(ClientFuture<Session> commitFuture, boolean startNew)
Commits the current transaction if one is active and is not failed into a roll-back only state.ClientTransactionContext
disposition(IncomingDelivery delivery, DeliveryState state, boolean settled)
Apply a disposition to the given delivery wrapping it with aTransactionalState
outcome if there is an active transaction.boolean
isInTransaction()
boolean
isRollbackOnly()
ClientTransactionContext
rollback(ClientFuture<Session> rollbackFuture, boolean startNew)
Rolls back the current transaction if one is active.ClientTransactionContext
send(ClientOutgoingEnvelope envelope, DeliveryState state, boolean settled)
Enlist the given outgoing envelope into this transaction if one is active and not already in a roll-back only state.
-
-
-
Method Detail
-
begin
ClientTransactionContext begin(ClientFuture<Session> beginFuture) throws ClientIllegalStateException
Begin a new transaction if one is not already in play.- Parameters:
beginFuture
- The future that awaits the result of starting the new transaction.- Returns:
- this
ClientTransactionContext
instance. - Throws:
ClientIllegalStateException
- if an error occurs do to the transaction state.
-
commit
ClientTransactionContext commit(ClientFuture<Session> commitFuture, boolean startNew) throws ClientIllegalStateException
Commits the current transaction if one is active and is not failed into a roll-back only state.- Parameters:
commitFuture
- The future that awaits the result of committing the new transaction.startNew
- Should the context immediately initiate a new transaction- Returns:
- this
ClientTransactionContext
instance. - Throws:
ClientIllegalStateException
- if an error occurs do to the transaction state.
-
rollback
ClientTransactionContext rollback(ClientFuture<Session> rollbackFuture, boolean startNew) throws ClientIllegalStateException
Rolls back the current transaction if one is active.- Parameters:
rollbackFuture
- The future that awaits the result of rolling back the new transaction.startNew
- Should the context immediately initiate a new transaction- Returns:
- this
ClientTransactionContext
instance. - Throws:
ClientIllegalStateException
- if an error occurs do to the transaction state.
-
isInTransaction
boolean isInTransaction()
- Returns:
- true if the context is hosting an active transaction.
-
isRollbackOnly
boolean isRollbackOnly()
- Returns:
- true if there is an active transaction but its state is failed an will roll-back
-
send
ClientTransactionContext send(ClientOutgoingEnvelope envelope, DeliveryState state, boolean settled)
Enlist the given outgoing envelope into this transaction if one is active and not already in a roll-back only state. If the transaction is failed the context should discard the envelope which should appear to the caller as if the send was successful.- Parameters:
envelope
- The envelope containing the details and mechanisms for sending the message.state
- The delivery state that is being applied as the outcome of the delivery.settled
- The settlement value that is being requested for the delivery.- Returns:
- this
ClientTransactionContext
instance.
-
disposition
ClientTransactionContext disposition(IncomingDelivery delivery, DeliveryState state, boolean settled)
Apply a disposition to the given delivery wrapping it with aTransactionalState
outcome if there is an active transaction. If there is no active transaction than the context will apply the disposition as requested but if there is an active transaction then the disposition must be wrapped in aTransactionalState
and settlement should always enforced by the client.- Parameters:
delivery
- The incoming delivery that the receiver is applying a disposition to.state
- The delivery state that is being applied as the outcome of the delivery.settled
- The settlement value that is being requested for the delivery.- Returns:
- this
ClientTransactionContext
instance.
-
-