public static class JmsMatsJmsSessionHandler_Pooling.JmsSessionHolderImpl extends java.lang.Object implements JmsMatsJmsSessionHandler.JmsSessionHolder, JmsMatsStatics
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicBoolean |
_closedOrCrashed |
protected JmsMatsJmsSessionHandler_Pooling.ConnectionWithSessionPool |
_connectionWithSessionPool |
protected java.lang.Object |
_currentContext |
protected javax.jms.Session |
_jmsSession |
protected javax.jms.MessageProducer |
_messageProducer |
EXTRA_GRACE_MILLIS, ILLEGAL_CALL_FLOWS, JMS_MSG_PROP_AUDIT, JMS_MSG_PROP_DISPATCH_TYPE, JMS_MSG_PROP_FROM, JMS_MSG_PROP_INITIALIZING_APP, JMS_MSG_PROP_INITIATOR_ID, JMS_MSG_PROP_MATS_MESSAGE_ID, JMS_MSG_PROP_MESSAGE_TYPE, JMS_MSG_PROP_TO, JMS_MSG_PROP_TRACE_ID, LOG_PREFIX, MAX_STACK_HEIGHT, MAX_TOTAL_CALL_NUMBER, MDC_MATS_APP_NAME, MDC_MATS_APP_VERSION, MDC_MATS_CALL_NUMBER, MDC_MATS_IN_MESSAGE_SYSTEM_ID, MDC_MATS_INIT, MDC_MATS_OUT_MATS_MESSAGE_ID, MDC_MATS_STAGE, MDC_MATS_STAGE_ID, MDC_TRACE_ID, NO_INVOCATION_POINT, RANDOM_ALPHABET, THREAD_PREFIX, TOTAL_JMS_MSG_PROPS_SIZE
Constructor and Description |
---|
JmsSessionHolderImpl(JmsMatsTransactionManager.JmsMatsTxContextKey txContextKey,
JmsMatsJmsSessionHandler_Pooling.ConnectionWithSessionPool connectionWithSessionPool,
javax.jms.Session jmsSession,
javax.jms.MessageProducer messageProducer) |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
crashed(java.lang.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
JmsMatsJmsSessionHandler.JmsSessionHolder.isSessionOk() returned false . |
javax.jms.MessageProducer |
getDefaultNoDestinationMessageProducer() |
javax.jms.Session |
getSession() |
void |
isSessionOk()
Shall be invoked at these points, with the action to perform if it raises
JmsMatsException.JmsMatsJmsException . |
void |
release()
For Initiators: This returns the JmsSessionHolder to the Session Pool for the underlying Connection.
|
protected void |
setCurrentContext(java.lang.Object currentContext) |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createFlowId, getInvocationPoint, handleIncomingMessageMatsObject, handleIncomingState, id, id, idThis, ms3, produceAndSendMsgSysMessages, randomString, setConcurrencyWithLog, stageOrInit
protected final JmsMatsJmsSessionHandler_Pooling.ConnectionWithSessionPool _connectionWithSessionPool
protected final javax.jms.Session _jmsSession
protected final javax.jms.MessageProducer _messageProducer
protected java.lang.Object _currentContext
protected java.util.concurrent.atomic.AtomicBoolean _closedOrCrashed
public JmsSessionHolderImpl(JmsMatsTransactionManager.JmsMatsTxContextKey txContextKey, JmsMatsJmsSessionHandler_Pooling.ConnectionWithSessionPool connectionWithSessionPool, javax.jms.Session jmsSession, javax.jms.MessageProducer messageProducer)
protected void setCurrentContext(java.lang.Object currentContext)
public void isSessionOk() throws JmsMatsException.JmsMatsJmsException
JmsMatsJmsSessionHandler.JmsSessionHolder
JmsMatsException.JmsMatsJmsException
.
JmsMatsException.JmsMatsJmsException
is
raised, JmsMatsJmsSessionHandler.JmsSessionHolder.close()
or JmsMatsJmsSessionHandler.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]JmsMatsException.JmsMatsJmsException
is raised, rollback shall be performed, JmsMatsJmsSessionHandler.JmsSessionHolder.close()
or
JmsMatsJmsSessionHandler.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.]isSessionOk
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
JmsMatsException.JmsMatsJmsException
public javax.jms.Session getSession()
getSession
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
public javax.jms.MessageProducer getDefaultNoDestinationMessageProducer()
getDefaultNoDestinationMessageProducer
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
MessageProducer
that goes along with the JMS
Session
.public void close()
JmsMatsJmsSessionHandler.JmsSessionHolder
close
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
public void release()
JmsMatsJmsSessionHandler.JmsSessionHolder
closed
or crashed
when inside the
JmsMatsTransactionManager
, in which case it should probably effectively act as a no-op.release
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
public void crashed(java.lang.Throwable t)
JmsMatsJmsSessionHandler.JmsSessionHolder
JmsMatsJmsSessionHandler.JmsSessionHolder.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 JmsMatsJmsSessionHandler.JmsSessionHolder.close()
, i.e. "come home as agreed upon,
whatever the state you are in".
crashed
in interface JmsMatsJmsSessionHandler.JmsSessionHolder
public java.lang.String toString()
toString
in class java.lang.Object