Class 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 Detail

      • JmsNoTxTransactionContext

        public JmsNoTxTransactionContext()
    • Method Detail

      • send

        public void send​(JmsConnection connection,
                         JmsOutboundMessageDispatch envelope,
                         ProviderSynchronization outcome)
                  throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        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.
        Specified by:
        send in interface JmsTransactionContext
        Parameters:
        connection - the connection that will be do the send of the message
        envelope - the envelope that contains the message to be sent.
        outcome - Synchronization used to set state prior to completion of the send call.
        Throws:
        javax.jms.JMSException - if an error occurs during the send.
      • acknowledge

        public void acknowledge​(JmsConnection connection,
                                JmsInboundMessageDispatch envelope,
                                ProviderConstants.ACK_TYPE ackType)
                         throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        Allows the context to intercept a message acknowledgement and perform any additional logic prior to the acknowledge being forwarded onto the connection.
        Specified by:
        acknowledge in interface JmsTransactionContext
        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:
        javax.jms.JMSException - if an error occurs while performing the acknowledge.
      • isInDoubt

        public boolean isInDoubt()
        Specified by:
        isInDoubt in interface JmsTransactionContext
        Returns:
        if the currently transaction has been marked as being in an unknown state.
      • begin

        public void begin()
                   throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        Start a transaction if none is currently active.
        Specified by:
        begin in interface JmsTransactionContext
        Throws:
        javax.jms.JMSException - on internal error occurs.
      • rollback

        public void rollback()
                      throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        Rolls 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:
        rollback in interface JmsTransactionContext
        Throws:
        javax.jms.JMSException - if the JMS provider fails to roll back the transaction due to some internal error.
      • shutdown

        public void shutdown()
                      throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        Rolls 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:
        shutdown in interface JmsTransactionContext
        Throws:
        javax.jms.JMSException - if the JMS provider fails to roll back the transaction due to some internal error.
      • commit

        public void commit()
                    throws javax.jms.JMSException
        Description copied from interface: JmsTransactionContext
        Commits 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:
        commit in interface JmsTransactionContext
        Throws:
        javax.jms.JMSException - if the commit fails to roll back the transaction due to some internal error.
      • setListener

        public void setListener​(JmsTransactionListener listener)
        Description copied from interface: JmsTransactionContext
        Sets the single JMS Transaction listener which will be notified of significant TX events such as Commit or Rollback.
        Specified by:
        setListener in interface JmsTransactionContext
        Parameters:
        listener - the JMS Transaction listener that will be sent all TX event notifications.
      • isInTransaction

        public boolean isInTransaction()
        Specified by:
        isInTransaction in interface JmsTransactionContext
        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: JmsTransactionContext
        Allows 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:
        isActiveInThisContext in interface JmsTransactionContext
        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: JmsTransactionContext
        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.
        Specified by:
        onConnectionInterrupted in interface JmsTransactionContext
      • onConnectionRecovery

        public void onConnectionRecovery​(Provider provider)
                                  throws java.lang.Exception
        Description copied from interface: JmsTransactionContext
        Called 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:
        onConnectionRecovery in interface JmsTransactionContext
        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.