Class JmsSessionManager

java.lang.Object
org.mule.jms.commons.internal.connection.session.JmsSessionManager

public class JmsSessionManager extends Object
Manager that takes the responsibility of register the session information to be able to execute a manual acknowledgement or a recover over a Session. This is used when the InternalAckMode is configured in InternalAckMode.MANUAL
Since:
1.0
  • Constructor Details

    • JmsSessionManager

      public JmsSessionManager()
  • Method Details

    • registerMessageForAck

      public void registerMessageForAck(String ackId, jakarta.jms.Message message, jakarta.jms.Session session, JmsListenerLock jmsLock)
      Registers the Message to the Session using the ackId in order to being able later to perform a InternalAckMode.MANUAL ACK
      Parameters:
      ackId - the id associated to the Session used to create the Message
      message - the Message to use for executing the Message.acknowledge()
      jmsLock - the optional JmsListenerLock to be able to unlock the JmsListener
      Throws:
      IllegalArgumentException - if no Session was registered with the given AckId
    • registerMessageForAck

      public void registerMessageForAck(String ackId, jakarta.jms.Message message, jakarta.jms.Session session, JmsListenerLock jmsLock, JmsMessageAckedMonitor jmsMessageAckedMonitor)
    • isPendingAck

      public boolean isPendingAck(String ackId)
    • ack

      public void ack(String ackId, AckCallback ackCallback)
      Executes the Message.acknowledge() on the latest Message associated to the Session identified by the ackId
      Parameters:
      ackId - the id associated to the Session that should be ACKed
    • recoverSession

      public void recoverSession(String ackId, AckCallback ackCallback)
      Executes the Session.recover() over the Session identified by the ackId
      Parameters:
      ackId - the id associated to the Session used to create the Message
    • bindToTransaction

      public void bindToTransaction(JmsSession session)
      Binds the given JmsSession to the current Thread
      Parameters:
      session - session to bind
    • bindToTransaction

      public void bindToTransaction(org.mule.runtime.extension.api.connectivity.XATransactionalConnection jmsXaTransactionalConnection, JmsSession session, JmsXaContext xaResource)
      Binds the given JmsSession and the correspondent XAResource to the current Thread
      Parameters:
      session - session to bind
    • unbindSession

      public void unbindSession()
      Unbinds the current JmsSession, if there is one, of the current Thread
    • unbindSession

      public void unbindSession(org.mule.runtime.extension.api.connectivity.XATransactionalConnection jmsXaTransactionalConnection)
      Unbinds the current JmsSession, if there is one, of the current Thread
    • getTransactedSession

      public Optional<JmsSession> getTransactedSession(JmsConnection connection)
      Returns:
      the Optional JmsSession of the current Thread
    • getXaTransactedSession

      public Optional<JmsSession> getXaTransactedSession(org.mule.runtime.extension.api.connectivity.XATransactionalConnection jmsXaTransactionalConnection)
    • getTransactionStatus

      public TransactionStatus getTransactionStatus()
      Returns:
      The status of the transaction. - TransactionStatus.NONE means that there is no started transaction for the current Thread - TransactionStatus.STARTED means that there is a transaction being executed in the current Thread
    • changeTransactionStatus

      public void changeTransactionStatus(TransactionStatus transactionStatus)
      Parameters:
      transactionStatus - The new TransactionStatus
    • getJmsXaContext

      public Optional<JmsXaContext> getJmsXaContext(JmsTransactionalConnection xaTransactionalConnection)
      Returns:
      the Optional JmsXaContext of the current Thread
    • getPendingAcknowledgements

      public Set<String> getPendingAcknowledgements()
      Returns the set of pending acknowledgements
      Returns:
      the set of pending acknowledgements