Interface JmsMatsJmsSessionHandler.JmsSessionHolder

All Known Implementing Classes:
JmsMatsJmsSessionHandler_Pooling.JmsSessionHolderImpl, JmsMatsJmsSessionHandler_Simple.JmsSessionHolder_Simple
Enclosing interface:
JmsMatsJmsSessionHandler

public static interface JmsMatsJmsSessionHandler.JmsSessionHolder
A "sidecar object" for the JMS Session, so that additional stuff can be bound to it.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Employed by StageProcessors: This physically closes the JMS Session, and removes it from the pool-Connection, and when all Sessions for a given pool-Connection is closed, the pool-Connection is closed.
    void
    Notifies that a Session (or "downstream" consumer or producer) raised some exception - probably due to some connectivity issues experienced as a JMSException while interacting with the JMS API, or because the isSessionOk() returned false.
    javax.jms.MessageProducer
     
    javax.jms.Session
     
    void
    Shall be invoked at these points, with the action to perform if it raises JmsMatsException.JmsMatsJmsException.
    void
    For Initiators: This returns the JmsSessionHolder to the Session Pool for the underlying Connection.
  • Method Details

    • isSessionOk

      void isSessionOk() throws JmsMatsException.JmsMatsJmsException
      Shall be invoked at these points, with the action to perform if it raises JmsMatsException.JmsMatsJmsException.
      1. (For StageProcessors) Before going into MessageConsumer.receive() - if JmsMatsException.JmsMatsJmsException is raised, close() or crashed(Throwable) shall be invoked, and then a new JmsSessionHolder shall be fetched. [This is to be able to signal to the StageProcessor that the underlying Connection might have become unstable - start afresh]
      2. (For StageProcessors and Initiators) Before committing any resources other than the JMS Session - if JmsMatsException.JmsMatsJmsException is raised, rollback shall be performed, close() or crashed(Throwable) shall be invoked, and then a new JmsSessionHolder shall be fetched. [This is to tighten the gap between typically the DB commit and the JMS commit: Just before the DB is committed, an invocation to this method is performed. If this goes OK, then the DB is committed and then the JMS Session is committed.]
      Throws:
      JmsMatsException.JmsMatsJmsException
    • getSession

      javax.jms.Session getSession()
      Returns:
      the JMS Session. It will be the same instance every time.
    • getDefaultNoDestinationMessageProducer

      javax.jms.MessageProducer getDefaultNoDestinationMessageProducer()
      Returns:
      the default non-specific MessageProducer that goes along with the JMS Session.
    • close

      void close()
      Employed by StageProcessors: This physically closes the JMS Session, and removes it from the pool-Connection, and when all Sessions for a given pool-Connection is closed, the pool-Connection is closed.
    • release

      void release()
      For Initiators: This returns the JmsSessionHolder to the Session Pool for the underlying Connection.

      Note: It is allowed to call this in a finally block after use, so it must guard against already having been closed or crashed when inside the JmsMatsTransactionManager, in which case it should probably effectively act as a no-op.

    • crashed

      void crashed(Throwable t)
      Notifies that a Session (or "downstream" consumer or producer) raised some exception - probably due to some connectivity issues experienced as a JMSException while interacting with the JMS API, or because the isSessionOk() returned false.

      This should close and ditch the Session, then the SessionHandler should (semantically) mark the underlying Connection as broken, and then then get all other "leasers" to come back with their sessions (close or crash), so that the Connection can be closed. The leasers should then get a new session by JmsMatsJmsSessionHandler.getSessionHolder(JmsMatsStageProcessor), which will be based on a fresh Connection.

      NOTE: If a session comes back with "crashed", but it has already been "revoked" by the SessionHandler due to another crash, this invocation should be equivalent to close(), i.e. "come home as agreed upon, whatever the state you are in".