Package io.mats3.spring.jms.factories
Class SpringJmsMatsFactoryProducer
java.lang.Object
io.mats3.spring.jms.factories.SpringJmsMatsFactoryProducer
Provides an easy way to get hold of the most probable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpringJmsMatsFactoryWrapper
createJmsTxOnlyMatsFactory
(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory) If you need aMatsFactory
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, usecreateSpringDataSourceTxMatsFactory(..)
instead.static SpringJmsMatsFactoryWrapper
createSpringDataSourceTxMatsFactory
(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, DataSource sqlDataSource) If you need aMatsFactory
employing Spring's DataSourceTransactionManager (which you probably do in a Spring environment utilizing SQL), this is your factory method.static SpringJmsMatsFactoryWrapper
createSpringPlatformTransactionManagerTxMatsFactory
(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, org.springframework.transaction.PlatformTransactionManager platformTransactionManager) If you need aMatsFactory
employing aPlatformTransactionManager
of your choosing, which you quite possibly want in a Spring environment using e.g.
-
Constructor Details
-
SpringJmsMatsFactoryProducer
public SpringJmsMatsFactoryProducer()
-
-
Method Details
-
createSpringDataSourceTxMatsFactory
public static SpringJmsMatsFactoryWrapper createSpringDataSourceTxMatsFactory(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, DataSource sqlDataSource) If you need aMatsFactory
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 SpringFactoryBean
where you then need to invokeSpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext)
.- Parameters:
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
- theJmsMatsFactory
utilizes theMatsSerializer
, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory
- the JMSConnectionFactory
to fetch JMS Connections from, usingConnectionFactory.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 SpringDataSourceTransactionManager
, and from which SQLConnection
s are fetched from, usingDataSource.getConnection()
. It is assumed that if username and password is needed, you have configured that on the DataSource.- Returns:
- the produced
SpringJmsMatsFactoryWrapper
-
createSpringPlatformTransactionManagerTxMatsFactory
public static SpringJmsMatsFactoryWrapper createSpringPlatformTransactionManagerTxMatsFactory(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, org.springframework.transaction.PlatformTransactionManager platformTransactionManager) If you need aMatsFactory
employing aPlatformTransactionManager
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 SpringFactoryBean
where you then need to invokeSpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext)
.- Parameters:
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
- theJmsMatsFactory
utilizes theMatsSerializer
, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory
- the JMSConnectionFactory
to fetch JMS Connections from, usingConnectionFactory.createConnection()
. It is assumed that if username and password is needed, you have configured that on the ConnectionFactory.platformTransactionManager
- thePlatformTransactionManager
(typicallyDataSourceTransactionManager
orHibernateTransactionManager)
that the MatsFactory should employ.- Returns:
- the produced
SpringJmsMatsFactoryWrapper
-
createJmsTxOnlyMatsFactory
public static SpringJmsMatsFactoryWrapper createJmsTxOnlyMatsFactory(String appName, String appVersion, MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory) If you need aMatsFactory
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, usecreateSpringDataSourceTxMatsFactory(..)
instead. Usage: Make a @Bean-annotated method which returns the result of this method, or employ a SpringFactoryBean
where you then need to invokeSpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext)
.- Parameters:
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
- theJmsMatsFactory
utilizes theMatsSerializer
, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory
- the JMSConnectionFactory
to fetch JMS Connections from, usingConnectionFactory.createConnection()
. It is assumed that if username and password is needed, you have configured that on the ConnectionFactory.- Returns:
- the produced
SpringJmsMatsFactoryWrapper
-