Package org.apache.qpid.jms
Class JmsNoTxTransactionContext
- java.lang.Object
-
- org.apache.qpid.jms.JmsNoTxTransactionContext
-
- All Implemented Interfaces:
JmsTransactionContext
public class JmsNoTxTransactionContext extends java.lang.Object implements JmsTransactionContext
Used in non-transacted JMS Sessions to throw proper errors indicating that the Session is not transacted and cannot be treated as such.
-
-
Constructor Summary
Constructors Constructor Description JmsNoTxTransactionContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacknowledge(JmsConnection connection, JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType)Allows the context to intercept a message acknowledgement and perform any additional logic prior to the acknowledge being forwarded onto the connection.voidbegin()Start a transaction if none is currently active.voidcommit()Commits all work done in this transaction and releases any locks currently held.JmsTransactionListenergetListener()JmsTransactionIdgetTransactionId()booleanisActiveInThisContext(JmsResourceId resouceId)Allows a resource to query the transaction context to determine if it has pending work in the current transaction.booleanisInDoubt()booleanisInTransaction()voidonConnectionInterrupted()Signals that the connection that was previously established has been lost and the listener should alter its state to reflect the fact that there is no active connection.voidonConnectionRecovery(Provider provider)Called when the connection to the remote peer has been lost and then a new connection established.voidrollback()Rolls back any work done in this transaction and releases any locks currently held.voidsend(JmsConnection connection, JmsOutboundMessageDispatch envelope, ProviderSynchronization outcome)Allows the context to intercept and perform any additional logic prior to a message being sent on to the connection and subsequently the remote peer.voidsetListener(JmsTransactionListener listener)Sets the single JMS Transaction listener which will be notified of significant TX events such as Commit or Rollback.voidshutdown()Rolls back any work done in this transaction and releases any locks currently held.
-
-
-
Method Detail
-
send
public void send(JmsConnection connection, JmsOutboundMessageDispatch envelope, ProviderSynchronization outcome) throws jakarta.jms.JMSException
Description copied from interface:JmsTransactionContextAllows the context to intercept and perform any additional logic prior to a message being sent on to the connection and subsequently the remote peer.- Specified by:
sendin interfaceJmsTransactionContext- Parameters:
connection- the connection that will be do the send of the messageenvelope- the envelope that contains the message to be sent.outcome- Synchronization used to set state prior to completion of the send call.- Throws:
jakarta.jms.JMSException- if an error occurs during the send.
-
acknowledge
public void acknowledge(JmsConnection connection, JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType) throws jakarta.jms.JMSException
Description copied from interface:JmsTransactionContextAllows the context to intercept a message acknowledgement and perform any additional logic prior to the acknowledge being forwarded onto the connection.- Specified by:
acknowledgein interfaceJmsTransactionContext- Parameters:
connection- the connection that the acknowledge will be forwarded to.envelope- the envelope that contains the message to be acknowledged.ackType- the acknowledgement type being requested.- Throws:
jakarta.jms.JMSException- if an error occurs while performing the acknowledge.
-
isInDoubt
public boolean isInDoubt()
- Specified by:
isInDoubtin interfaceJmsTransactionContext- Returns:
- if the currently transaction has been marked as being in an unknown state.
-
begin
public void begin() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsTransactionContextStart a transaction if none is currently active.- Specified by:
beginin interfaceJmsTransactionContext- Throws:
jakarta.jms.JMSException- on internal error occurs.
-
rollback
public void rollback() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsTransactionContextRolls back any work done in this transaction and releases any locks currently held. If the current transaction is in a failed state this resets that state and initiates a new transaction via a begin call.- Specified by:
rollbackin interfaceJmsTransactionContext- Throws:
jakarta.jms.JMSException- if the JMS provider fails to roll back the transaction due to some internal error.
-
shutdown
public void shutdown() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsTransactionContextRolls back any work done in this transaction and releases any locks currently held. This method will not start a new transaction and no new transacted work should be done using this transaction.- Specified by:
shutdownin interfaceJmsTransactionContext- Throws:
jakarta.jms.JMSException- if the JMS provider fails to roll back the transaction due to some internal error.
-
commit
public void commit() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsTransactionContextCommits all work done in this transaction and releases any locks currently held. If the transaction is in a failed state this method throws an exception to indicate that the transaction has failed and will be rolled back a new transaction is started via a begin call.- Specified by:
commitin interfaceJmsTransactionContext- Throws:
jakarta.jms.JMSException- if the commit fails to roll back the transaction due to some internal error.
-
getTransactionId
public JmsTransactionId getTransactionId()
- Specified by:
getTransactionIdin interfaceJmsTransactionContext- Returns:
- the transaction ID of the currently active TX or null if none active.
-
getListener
public JmsTransactionListener getListener()
- Specified by:
getListenerin interfaceJmsTransactionContext- Returns:
- the currently configured JMS Transaction listener which will receive TX events.
-
setListener
public void setListener(JmsTransactionListener listener)
Description copied from interface:JmsTransactionContextSets the single JMS Transaction listener which will be notified of significant TX events such as Commit or Rollback.- Specified by:
setListenerin interfaceJmsTransactionContext- Parameters:
listener- the JMS Transaction listener that will be sent all TX event notifications.
-
isInTransaction
public boolean isInTransaction()
- Specified by:
isInTransactionin interfaceJmsTransactionContext- Returns:
- true if there is a transaction in progress even if the current is failed.
-
isActiveInThisContext
public boolean isActiveInThisContext(JmsResourceId resouceId)
Description copied from interface:JmsTransactionContextAllows a resource to query the transaction context to determine if it has pending work in the current transaction. Callers should use caution with this method as it is only a view into the current state without blocking ongoing transaction operations. The best use of this method is in the validation method of a JmsTransactionSynchronization to determine if the synchronization needs to be added based on whether to requesting resource has any pending operations.- Specified by:
isActiveInThisContextin interfaceJmsTransactionContext- Parameters:
resouceId- The JmsResourceId of the resource making this query.- Returns:
- true if the resource has pending work in the current transaction.
-
onConnectionInterrupted
public void onConnectionInterrupted()
Description copied from interface:JmsTransactionContextSignals that the connection that was previously established has been lost and the listener should alter its state to reflect the fact that there is no active connection.- Specified by:
onConnectionInterruptedin interfaceJmsTransactionContext
-
onConnectionRecovery
public void onConnectionRecovery(Provider provider) throws java.lang.Exception
Description copied from interface:JmsTransactionContextCalled when the connection to the remote peer has been lost and then a new connection established. The context should perform any necessary processing recover and reset its internal state.- Specified by:
onConnectionRecoveryin interfaceJmsTransactionContext- Parameters:
provider- A reference to the provider that manages the new connection.- Throws:
java.lang.Exception- if an error occurs while rebuilding against the new provider.
-
-