public class JmsMatsTransactionManager_JmsAndJdbc extends JmsMatsTransactionManager_Jms
JmsMatsTransactionManager
that in addition to the JMS transaction also handles a JDBC SQL
Connection
(using only pure java, i.e. no Spring) for which it keeps transaction demarcation along with the
JMS transaction, by means of "Best Effort 1 Phase Commit":
JmsMatsTransactionManager_Jms
) - and then the Message Broker will probably try to redeliver the message. Also
read the Should I use XA Transactions from Apache
Active MQ.
Wise tip when working with Message Oriented Middleware: Code idempotent! Handle double-deliveries!
The transactionally demarcated SQL Connection can be retrieved from user code using
ProcessContext.getAttribute(Connection.class)
.
It requires a DataSource
upon construction. The DataSource
will be asked for a SQL Connection in any
MatsStage's StageProcessor that requires it: The fetching of the SQL Connection is lazy in that it won't be retrieved
(nor entered into transaction with), until it is actually requested by the user code by means of
ProcessContext.getAttribute(Connection.class)
.
The SQL Connection will be closed
after each stage processing (after each transaction,
either committed or rollbacked) - if it was requested during the user code.
This implementation will not perform any Connection reuse (caching/pooling). It is up to the supplier to implement any pooling, or make use of a pooled DataSource, if so desired. (Which definitely should be desired, due to the heavy use of "get new - use - commit/rollback - close".)
Modifier and Type | Class and Description |
---|---|
static class |
JmsMatsTransactionManager_JmsAndJdbc.TransactionalContext_JmsAndJdbc
The
TransactionContext -implementation for JmsMatsTransactionManager_Jms . |
JmsMatsTransactionManager_Jms.TransactionalContext_Jms
JmsMatsTransactionManager.JmsMatsTxContextKey, JmsMatsTransactionManager.ProcessingLambda, JmsMatsTransactionManager.TransactionContext
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
Modifier | Constructor and Description |
---|---|
protected |
JmsMatsTransactionManager_JmsAndJdbc(javax.sql.DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
static JmsMatsTransactionManager_JmsAndJdbc |
create(javax.sql.DataSource dataSource) |
JmsMatsTransactionManager.TransactionContext |
getTransactionContext(JmsMatsTransactionManager.JmsMatsTxContextKey txContextKey)
Provides an implementation of
JmsMatsTransactionManager.TransactionContext . |
create
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createFlowId, getInvocationPoint, handleIncomingMessageMatsObject, handleIncomingState, id, id, idThis, ms3, produceAndSendMsgSysMessages, randomString, setConcurrencyWithLog, stageOrInit
protected JmsMatsTransactionManager_JmsAndJdbc(javax.sql.DataSource dataSource)
public static JmsMatsTransactionManager_JmsAndJdbc create(javax.sql.DataSource dataSource)
public JmsMatsTransactionManager.TransactionContext getTransactionContext(JmsMatsTransactionManager.JmsMatsTxContextKey txContextKey)
JmsMatsTransactionManager
JmsMatsTransactionManager.TransactionContext
. (JMS Connection and Session handling is done by
JmsMatsJmsSessionHandler
).getTransactionContext
in interface JmsMatsTransactionManager
getTransactionContext
in class JmsMatsTransactionManager_Jms
txContextKey
- for which JmsMatsStage
or JmsMatsInitiator
this request for JmsMatsTransactionManager.TransactionContext
is for.JmsMatsTransactionManager.TransactionContext
for the supplied txContextKey.