Package io.mats3.impl.jms
Class JmsMatsJmsSessionHandler_Simple.JmsSessionHolder_Simple
java.lang.Object
io.mats3.impl.jms.JmsMatsJmsSessionHandler_Simple.JmsSessionHolder_Simple
- All Implemented Interfaces:
- JmsMatsJmsSessionHandler.JmsSessionHolder
- Enclosing class:
- JmsMatsJmsSessionHandler_Simple
public class JmsMatsJmsSessionHandler_Simple.JmsSessionHolder_Simple
extends Object
implements JmsMatsJmsSessionHandler.JmsSessionHolder
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AtomicBooleanprotected final javax.jms.Connectionprotected final javax.jms.Sessionprotected final javax.jms.MessageProducer
- 
Constructor SummaryConstructorsConstructorDescriptionJmsSessionHolder_Simple(javax.jms.Connection jmsConnection, javax.jms.Session jmsSession, javax.jms.MessageProducer messageProducer) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()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.voidNotifies 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 theJmsMatsJmsSessionHandler.JmsSessionHolder.isSessionOk()returnedfalse.javax.jms.MessageProducerjavax.jms.SessionvoidShall be invoked at these points, with the action to perform if it raisesJmsMatsException.JmsMatsJmsException.voidrelease()For Initiators: This returns the JmsSessionHolder to the Session Pool for the underlying Connection.
- 
Field Details- 
_jmsConnectionprotected final javax.jms.Connection _jmsConnection
- 
_jmsSessionprotected final javax.jms.Session _jmsSession
- 
_messageProducerprotected final javax.jms.MessageProducer _messageProducer
- 
_closedOrReleasedOrCrashed
 
- 
- 
Constructor Details- 
JmsSessionHolder_Simplepublic JmsSessionHolder_Simple(javax.jms.Connection jmsConnection, javax.jms.Session jmsSession, javax.jms.MessageProducer messageProducer) 
 
- 
- 
Method Details- 
isSessionOkDescription copied from interface:JmsMatsJmsSessionHandler.JmsSessionHolderShall be invoked at these points, with the action to perform if it raisesJmsMatsException.JmsMatsJmsException.- (For StageProcessors) Before going into MessageConsumer.receive() - if JmsMatsException.JmsMatsJmsExceptionis raised,JmsMatsJmsSessionHandler.JmsSessionHolder.close()orJmsMatsJmsSessionHandler.JmsSessionHolder.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]
- (For StageProcessors and Initiators) Before committing any resources other than the JMS Session - if
 JmsMatsException.JmsMatsJmsExceptionis raised, rollback shall be performed,JmsMatsJmsSessionHandler.JmsSessionHolder.close()orJmsMatsJmsSessionHandler.JmsSessionHolder.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.]
 - Specified by:
- isSessionOkin interface- JmsMatsJmsSessionHandler.JmsSessionHolder
- Throws:
- JmsMatsException.JmsMatsJmsException
 
- (For StageProcessors) Before going into MessageConsumer.receive() - if 
- 
getSessionpublic javax.jms.Session getSession()- Specified by:
- getSessionin interface- JmsMatsJmsSessionHandler.JmsSessionHolder
- Returns:
- the JMS Session. It will be the same instance every time.
 
- 
getDefaultNoDestinationMessageProducerpublic javax.jms.MessageProducer getDefaultNoDestinationMessageProducer()- Specified by:
- getDefaultNoDestinationMessageProducerin interface- JmsMatsJmsSessionHandler.JmsSessionHolder
- Returns:
- the default non-specific MessageProducerthat goes along withthe JMS Session.
 
- 
closepublic void close()Description copied from interface:JmsMatsJmsSessionHandler.JmsSessionHolderEmployed 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.- Specified by:
- closein interface- JmsMatsJmsSessionHandler.JmsSessionHolder
 
- 
releasepublic void release()Description copied from interface:JmsMatsJmsSessionHandler.JmsSessionHolderFor 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 beenclosedorcrashedwhen inside theJmsMatsTransactionManager, in which case it should probably effectively act as a no-op.- Specified by:
- releasein interface- JmsMatsJmsSessionHandler.JmsSessionHolder
 
- 
crashedDescription copied from interface:JmsMatsJmsSessionHandler.JmsSessionHolderNotifies 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 theJmsMatsJmsSessionHandler.JmsSessionHolder.isSessionOk()returnedfalse.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 JmsMatsJmsSessionHandler.JmsSessionHolder.close(), i.e. "come home as agreed upon, whatever the state you are in".- Specified by:
- crashedin interface- JmsMatsJmsSessionHandler.JmsSessionHolder
 
 
-