Package io.mats3.impl.jms
Class JmsMatsJmsSessionHandler_Simple
java.lang.Object
io.mats3.impl.jms.JmsMatsJmsSessionHandler_Simple
- All Implemented Interfaces:
JmsMatsJmsSessionHandler
,JmsMatsStatics
public class JmsMatsJmsSessionHandler_Simple
extends Object
implements JmsMatsJmsSessionHandler, JmsMatsStatics
A dead simple implementation of
JmsMatsJmsSessionHandler
which does nothing of pooling nor connection
sharing. For StageProcessors (endpoints), this actually is one of the interesting options: Each StageProcessor has
its own Connection with a sole Session. But for Initiators, it is pretty bad: Each initiation constructs one
Connection (with a sole Session), and then closes the whole thing down after the initiation is done (message(s) is
sent).-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.mats3.impl.jms.JmsMatsJmsSessionHandler
JmsMatsJmsSessionHandler.JmsSessionHolder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final javax.jms.ConnectionFactory
protected AtomicInteger
Fields inherited from interface io.mats3.impl.jms.JmsMatsStatics
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_MATS_STAGE_INDEX, MDC_TRACE_ID, NO_INVOCATION_POINT, RANDOM_ALPHABET, THREAD_PREFIX, TOTAL_JMS_MSG_PROPS_SIZE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JmsMatsJmsSessionHandler_Simple
(javax.jms.ConnectionFactory jmsConnectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionint
Closes all Available Session, does not touch Employed.create
(javax.jms.ConnectionFactory connectionFactory) getSessionHolder
(io.mats3.impl.jms.JmsMatsInitiator<?> initiator) Will be invoked every time an Initiator wants to send a message - it will be returned after the message(s) is sent.getSessionHolder
(io.mats3.impl.jms.JmsMatsStageProcessor<?, ?, ?, ?> stageProcessor) Will be invoked before the StageProcessor goes into its consumer loop - it will be closed once the Stage is stopped, or if the Session "crashes", i.e.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.mats3.impl.jms.JmsMatsStatics
createFlowId, getInvocationPoint, id, id, idThis, ms3, produceAndSendMsgSysMessages, randomString, setConcurrencyWithLog, stageOrInit
-
Field Details
-
_jmsConnectionFactory
protected final javax.jms.ConnectionFactory _jmsConnectionFactory -
_numberOfOutstandingConnections
-
-
Constructor Details
-
JmsMatsJmsSessionHandler_Simple
protected JmsMatsJmsSessionHandler_Simple(javax.jms.ConnectionFactory jmsConnectionFactory)
-
-
Method Details
-
create
-
getSessionHolder
public JmsMatsJmsSessionHandler.JmsSessionHolder getSessionHolder(io.mats3.impl.jms.JmsMatsInitiator<?> initiator) throws JmsMatsException.JmsMatsJmsException Description copied from interface:JmsMatsJmsSessionHandler
Will be invoked every time an Initiator wants to send a message - it will be returned after the message(s) is sent.- Specified by:
getSessionHolder
in interfaceJmsMatsJmsSessionHandler
- Parameters:
initiator
- the initiator in question.- Returns:
- a
JmsMatsJmsSessionHandler.JmsSessionHolder
instance - which is not the same as any other SessionHolders concurrently in use (but it may be pooled, so after aJmsMatsJmsSessionHandler.JmsSessionHolder.release()
, it may be returned to another invocation again). - Throws:
JmsMatsException.JmsMatsJmsException
- if there was a problem getting a Connection. Problems getting a Sessions (e.g. the current Connection is broken) should be internally handled (i.e. try to get a new Connection), except if it can be determined that the problem getting a Session is of a fundamental nature (i.e. the credentials can get a Connection, but cannot get a Session - which would be pretty absurd, but hey).
-
getSessionHolder
public JmsMatsJmsSessionHandler.JmsSessionHolder getSessionHolder(io.mats3.impl.jms.JmsMatsStageProcessor<?, ?, throws JmsMatsException.JmsMatsJmsException?, ?> stageProcessor) Description copied from interface:JmsMatsJmsSessionHandler
Will be invoked before the StageProcessor goes into its consumer loop - it will be closed once the Stage is stopped, or if the Session "crashes", i.e. a method on Session or some downstream API throws an Exception.- Specified by:
getSessionHolder
in interfaceJmsMatsJmsSessionHandler
- Parameters:
stageProcessor
- the StageProcessor in question.- Returns:
- a
JmsMatsJmsSessionHandler.JmsSessionHolder
instance - which is unique for each call. - Throws:
JmsMatsException.JmsMatsJmsException
- if there was a problem getting a Connection. Problems getting a Sessions (e.g. the current Connection is broken) should be internally handled (i.e. try to get a new Connection), except if it can be determined that the problem getting a Session is of a fundamental nature (i.e. the credentials can get a Connection, but cannot get a Session - which would be pretty absurd, but hey).
-
closeAllAvailableSessions
public int closeAllAvailableSessions()Description copied from interface:JmsMatsJmsSessionHandler
Closes all Available Session, does not touch Employed. Net result is that it Connections that do not have any employed Sessions will be closed. The use case for this is to "clear out" theJmsMatsJmsSessionHandler
upon shutdown - the returned value is a count of how many Connections are still alive after the operation, which should be 0.- Specified by:
closeAllAvailableSessions
in interfaceJmsMatsJmsSessionHandler
- Returns:
- the number of Connections still alive after the operation (in the assumed use case, this should be zero).
-
getSessionHolder_internal
protected JmsMatsJmsSessionHandler.JmsSessionHolder getSessionHolder_internal(JmsMatsTransactionManager.JmsMatsTxContextKey txContextKey) throws JmsMatsException.JmsMatsJmsException
-