public class SpringJmsMatsFactoryProducer
extends java.lang.Object
JmsMatsFactory transaction manager configuration in the
Spring world (using JmsMatsTransactionManager_JmsAndSpringManagedSqlTx, or only the
JmsMatsTransactionManager_Jms if no DataSource is needed). You may either supply a DataSource, or a
Spring PlatformTransactionManager (typically DataSourceTransactionManager or
HibernateTransactionManager). The code here is very simple, really just creating the MatsFactory
normally and then wrapping it up in a SpringJmsMatsFactoryWrapper which provides hook-in to the Spring
context (read more about those hook-in features on its JavaDoc).
NOTE: It returns an instance of SpringJmsMatsFactoryWrapper, which it is assumed that you put in the
Spring context as a bean, so that Spring property injection and @PostConstruct is run on it. If you
instead employ a FactoryBean (e.g. because you have made a cool Mats single-annotation-configuration solution
for your multiple codebases), then you need to invoke
SpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext) - read up!| Constructor and Description |
|---|
SpringJmsMatsFactoryProducer() |
| Modifier and Type | Method and Description |
|---|---|
static SpringJmsMatsFactoryWrapper |
createJmsTxOnlyMatsFactory(java.lang.String appName,
java.lang.String appVersion,
MatsSerializer<?> matsSerializer,
javax.jms.ConnectionFactory jmsConnectionFactory)
If you need a
MatsFactory that only handles the JMS transactions, this is your factory method - but if
you DO make any database calls within any Mats endpoint lambda, you will now have no or poor transactional
demarcation, use
createSpringDataSourceTxMatsFactory(..) instead. |
static SpringJmsMatsFactoryWrapper |
createSpringDataSourceTxMatsFactory(java.lang.String appName,
java.lang.String appVersion,
MatsSerializer<?> matsSerializer,
javax.jms.ConnectionFactory jmsConnectionFactory,
javax.sql.DataSource sqlDataSource)
If you need a
MatsFactory employing Spring's DataSourceTransactionManager (which you probably do in a
Spring environment utilizing SQL), this is your factory method. |
static SpringJmsMatsFactoryWrapper |
createSpringPlatformTransactionManagerTxMatsFactory(java.lang.String appName,
java.lang.String appVersion,
MatsSerializer<?> matsSerializer,
javax.jms.ConnectionFactory jmsConnectionFactory,
org.springframework.transaction.PlatformTransactionManager platformTransactionManager)
If you need a
MatsFactory employing a PlatformTransactionManager of your choosing, which you
quite possibly want in a Spring environment using e.g. |
public static SpringJmsMatsFactoryWrapper createSpringDataSourceTxMatsFactory(java.lang.String appName, java.lang.String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, javax.sql.DataSource sqlDataSource)
MatsFactory employing Spring's DataSourceTransactionManager (which you probably do in a
Spring environment utilizing SQL), this is your factory method.
Usage: Make a @Bean-annotated method which returns the result of this method, or employ a Spring
FactoryBean where you then need to invoke
SpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext).appName - the containing application's name (for debugging purposes, you'll find it in the trace).appVersion - the containing application's version (for debugging purposes, you'll find it in the trace).matsSerializer - the JmsMatsFactory utilizes the MatsSerializer, so you need to provide one. (It is
probably the one from the 'mats-serial-json' package).jmsConnectionFactory - the JMS ConnectionFactory to fetch JMS Connections from, using
ConnectionFactory.createConnection(). It is assumed that if username and password is needed,
you have configured that on the ConnectionFactory.sqlDataSource - the SQL DataSource which to stash into a Spring DataSourceTransactionManager, and from which
SQL Connections are fetched from, using DataSource.getConnection(). It is assumed that
if username and password is needed, you have configured that on the DataSource.SpringJmsMatsFactoryWrapperpublic static SpringJmsMatsFactoryWrapper createSpringPlatformTransactionManagerTxMatsFactory(java.lang.String appName, java.lang.String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, org.springframework.transaction.PlatformTransactionManager platformTransactionManager)
MatsFactory employing a PlatformTransactionManager of your choosing, which you
quite possibly want in a Spring environment using e.g. Spring JDBC or Hibernate, this is your factory method.
Usage: Make a @Bean-annotated method which returns the result of this method, or employ a Spring
FactoryBean where you then need to invoke
SpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext).appName - the containing application's name (for debugging purposes, you'll find it in the trace).appVersion - the containing application's version (for debugging purposes, you'll find it in the trace).matsSerializer - the JmsMatsFactory utilizes the MatsSerializer, so you need to provide one. (It is
probably the one from the 'mats-serial-json' package).jmsConnectionFactory - the JMS ConnectionFactory to fetch JMS Connections from, using
ConnectionFactory.createConnection(). It is assumed that if username and password is needed,
you have configured that on the ConnectionFactory.platformTransactionManager - the PlatformTransactionManager (typically DataSourceTransactionManager or
HibernateTransactionManager) that the MatsFactory should employ.SpringJmsMatsFactoryWrapperpublic static SpringJmsMatsFactoryWrapper createJmsTxOnlyMatsFactory(java.lang.String appName, java.lang.String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory)
MatsFactory that only handles the JMS transactions, this is your factory method - but if
you DO make any database calls within any Mats endpoint lambda, you will now have no or poor transactional
demarcation, use
createSpringDataSourceTxMatsFactory(..) instead.
Usage: Make a @Bean-annotated method which returns the result of this method, or employ a Spring
FactoryBean where you then need to invoke
SpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext).appName - the containing application's name (for debugging purposes, you'll find it in the trace).appVersion - the containing application's version (for debugging purposes, you'll find it in the trace).matsSerializer - the JmsMatsFactory utilizes the MatsSerializer, so you need to provide one. (It is
probably the one from the 'mats-serial-json' package).jmsConnectionFactory - the JMS ConnectionFactory to fetch JMS Connections from, using
ConnectionFactory.createConnection(). It is assumed that if username and password is needed,
you have configured that on the ConnectionFactory.SpringJmsMatsFactoryWrapper