Package io.mats3.spring.jms.factories
Class SpringJmsMatsFactoryProducer
- java.lang.Object
-
- io.mats3.spring.jms.factories.SpringJmsMatsFactoryProducer
-
public class SpringJmsMatsFactoryProducer extends java.lang.ObjectProvides an easy way to get hold of the most probableJmsMatsFactorytransaction manager configuration in the Spring world (usingJmsMatsTransactionManager_JmsAndSpringManagedSqlTx, or only theJmsMatsTransactionManager_Jmsif no DataSource is needed). You may either supply aDataSource, or a SpringPlatformTransactionManager(typicallyDataSourceTransactionManagerorHibernateTransactionManager). The code here is very simple, really just creating theMatsFactorynormally and then wrapping it up in aSpringJmsMatsFactoryWrapperwhich provides hook-in to the Spring context (read more about those hook-in features on itsJavaDoc). NOTE: It returns an instance ofSpringJmsMatsFactoryWrapper, which it is assumed that you put in the Spring context as a bean, so that Spring property injection and@PostConstructis 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 invokeSpringJmsMatsFactoryWrapper.postConstructForFactoryBean(Environment, ApplicationContext)- read up!
-
-
Constructor Summary
Constructors Constructor Description SpringJmsMatsFactoryProducer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SpringJmsMatsFactoryWrappercreateJmsTxOnlyMatsFactory(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory)If you need aMatsFactorythat 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 SpringJmsMatsFactoryWrappercreateSpringDataSourceTxMatsFactory(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, javax.sql.DataSource sqlDataSource)If you need aMatsFactoryemploying Spring's DataSourceTransactionManager (which you probably do in a Spring environment utilizing SQL), this is your factory method.static SpringJmsMatsFactoryWrappercreateSpringPlatformTransactionManagerTxMatsFactory(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, org.springframework.transaction.PlatformTransactionManager platformTransactionManager)If you need aMatsFactoryemploying aPlatformTransactionManagerof your choosing, which you quite possibly want in a Spring environment using e.g.
-
-
-
Method Detail
-
createSpringDataSourceTxMatsFactory
public static SpringJmsMatsFactoryWrapper createSpringDataSourceTxMatsFactory(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, javax.sql.DataSource sqlDataSource)
If you need aMatsFactoryemploying 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 SpringFactoryBeanwhere 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- theJmsMatsFactoryutilizes theMatsSerializer, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory- the JMSConnectionFactoryto 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 SQLConnections 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(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory, org.springframework.transaction.PlatformTransactionManager platformTransactionManager)
If you need aMatsFactoryemploying aPlatformTransactionManagerof 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 SpringFactoryBeanwhere 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- theJmsMatsFactoryutilizes theMatsSerializer, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory- the JMSConnectionFactoryto 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(typicallyDataSourceTransactionManagerorHibernateTransactionManager)that the MatsFactory should employ.- Returns:
- the produced
SpringJmsMatsFactoryWrapper
-
createJmsTxOnlyMatsFactory
public static SpringJmsMatsFactoryWrapper createJmsTxOnlyMatsFactory(java.lang.String appName, java.lang.String appVersion, io.mats3.serial.MatsSerializer<?> matsSerializer, javax.jms.ConnectionFactory jmsConnectionFactory)
If you need aMatsFactorythat 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 SpringFactoryBeanwhere 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- theJmsMatsFactoryutilizes theMatsSerializer, so you need to provide one. (It is probably the one from the 'mats-serial-json' package).jmsConnectionFactory- the JMSConnectionFactoryto 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
-
-