本文整理汇总了Java中com.atomikos.icatch.jta.UserTransactionManager类的典型用法代码示例。如果您正苦于以下问题:Java UserTransactionManager类的具体用法?Java UserTransactionManager怎么用?Java UserTransactionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserTransactionManager类属于com.atomikos.icatch.jta包,在下文中一共展示了UserTransactionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createThreadsWithWorkers
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Override
protected List<Thread> createThreadsWithWorkers(T config) throws JMSException {
MessageProvider messageProvider;
try {
messageProvider = config.createMessageProvider();
}
catch (IOException e) {
throw new UncheckedIOException("Failed to initialize message provider", e);
}
Counter counter = config.createMessageCounter();
StopController stopController = config.createStopController(counter);
ResourceManagerFactory resourceManagerFactory = config.useXa()
? new XAJmsResourceManagerFactory(new UserTransactionManager(), config.createXAConnectionFactory(),
config.getDestinationName(), config.isDestinationTypeQueue())
: new JmsResourceManagerFactory(config.createConnectionFactory(), config.getDestinationName(),
config.isDestinationTypeQueue());
List<Thread> threads = createThreads(resourceManagerFactory, counter, stopController, messageProvider, config);
if (config.isStatisticsEnabled()) {
threads.add(new Thread(new StatisticsLogger(stopController, counter), "StatisticsLogger"));
}
return threads;
}
示例2: createThreadsWithWorkers
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Override
protected List<Thread> createThreadsWithWorkers(T config) throws JMSException {
Counter messageCounter = config.createMessageCounter();
Counter receiveTimeoutCounter = config.createReceiveTimeoutCounter();
StopController stopController = config.createStopController(messageCounter, receiveTimeoutCounter);
ResourceManagerFactory resourceManagerFactory = config.useXa()
? new XAJmsResourceManagerFactory(new UserTransactionManager(), config.createXAConnectionFactory(),
config.getDestinationName(), config.isDestinationTypeQueue())
: new JmsResourceManagerFactory(config.createConnectionFactory(), config.getDestinationName(),
config.isDestinationTypeQueue());
List<Thread> threads = createThreads(resourceManagerFactory, messageCounter, receiveTimeoutCounter,
stopController, config);
if (config.isStatisticsEnabled()) {
threads.add(new Thread(new StatisticsLogger(stopController, messageCounter, receiveTimeoutCounter),
"StatisticsLogger"));
}
return threads;
}
示例3: getTransactionAssistant
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
/** before calling this method, please ensure you have called {@link TransactionConfigurator#setup(String, CommitRollbackCallback)} */
@Override
public TransactionAssistant getTransactionAssistant() throws ResourceException {
//enlist a new resource into the transaction. it will be delisted, when its closed.
final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName);
MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback);
UserTransactionManager utm = getTM();
try {
if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){
throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus());
}
Transaction tx = utm.getTransaction();
tx.enlistResource(ms);
return new AtomikosTransactionAssistantImpl(ms);
} catch (Exception e) {
throw new ResourceException("Unable to get transaction status", e);
}
}
示例4: testNoTX
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Test
public void testNoTX() throws ResourceException, IllegalStateException, RollbackException, SystemException {
final UserTransactionManager tm = mock(UserTransactionManager.class);
when(tm.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION);
BasicTransactionAssistanceFactory f = new BasicTransactionAssistanceFactoryImpl("a"){
@Override
protected UserTransactionManager getTM() {
return tm;
}
};
try{
//TEST
f.getTransactionAssistant();
fail("no exception");
}catch(ResourceException e){
//OK, expected
}
}
示例5: init
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
public static void init() {
utm = new UserTransactionManager();
try {
utm.init();
adsb = new AtomikosDataSourceBean();
adsb.setMaxPoolSize(20);
adsb.setUniqueResourceName("postgres");
adsb.setXaDataSourceClassName("org.postgresql.xa.PGXADataSource");
Properties p = new Properties();
p.setProperty("user", "postgres");
p.setProperty("password", "0");
p.setProperty("serverName", "localhost");
p.setProperty("portNumber", "5432");
p.setProperty("databaseName", "postgres");
adsb.setXaProperties(p);
} catch (SystemException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例6: atomikosTransactionManager
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
/**
* Atomikos transaction manager.
* @return atomikos transaction manager
*/
@Bean(initMethod = "init", destroyMethod = "close")
public TransactionManager atomikosTransactionManager() {
final UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
return userTransactionManager;
}
示例7: AtomikosJtaPlatform
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
/**
* Default constructor.
*/
public AtomikosJtaPlatform() {
atomikosUserTransactionManager = new UserTransactionManager();
/*
* De Transaction Service moet op dit punt eigenlijk al opgestart zijn. Als dit niet het geval is,
* is hoogstwaarschijnlijk de volgorde van het laden van de config van de entitymanager en de transaction service
* verkeerd. Het hier laten starten van de transaction service leidt in dat geval tot verschillende
* gestarte transaction services. Dit kan vervolgens resulteren in verschillende transaction managers
* die elkaars context niet zien.
*/
atomikosUserTransactionManager.setStartupTransactionService(false);
}
示例8: atomikosTransactionManager
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
public UserTransactionManager atomikosTransactionManager() {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
userTransactionManager.setStartupTransactionService(false);
return userTransactionManager;
}
示例9: UserTransactionManager
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
@DependsOn("userTransactionService")
public UserTransactionManager UserTransactionManager() {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
userTransactionManager.setStartupTransactionService(false);
return userTransactionManager;
}
示例10: postProcessBeanFactory
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
String[] transactionManagers = beanFactory
.getBeanNamesForType(UserTransactionManager.class, true, false);
for (String transactionManager : transactionManagers) {
addTransactionManagerDependencies(beanFactory, transactionManager);
}
addMessageDrivenContainerDependencies(beanFactory, transactionManagers);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:AtomikosDependsOnBeanFactoryPostProcessor.java
示例11: atomikosTransactionManager
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
@ConditionalOnMissingBean
public UserTransactionManager atomikosTransactionManager(
UserTransactionService userTransactionService) throws Exception {
UserTransactionManager manager = new UserTransactionManager();
manager.setStartupTransactionService(false);
manager.setForceShutdown(true);
return manager;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:AtomikosJtaConfiguration.java
示例12: atomikosSanityCheck
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Test
public void atomikosSanityCheck() throws Exception {
this.context = new AnnotationConfigApplicationContext(JtaProperties.class,
AtomikosJtaConfiguration.class);
this.context.getBean(AtomikosProperties.class);
this.context.getBean(UserTransactionService.class);
this.context.getBean(UserTransactionManager.class);
this.context.getBean(UserTransaction.class);
this.context.getBean(XADataSourceWrapper.class);
this.context.getBean(XAConnectionFactoryWrapper.class);
this.context.getBean(AtomikosDependsOnBeanFactoryPostProcessor.class);
this.context.getBean(JtaTransactionManager.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JtaAutoConfigurationTests.java
示例13: atomikosTransactionManager
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Bean(name = "atomikosTransactionManager", initMethod = "init", destroyMethod = "close")
public TransactionManager atomikosTransactionManager() throws Throwable {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
AtomikosJtaPlatform.transactionManager = userTransactionManager;
return userTransactionManager;
}
示例14: contextDestroyed
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Override
public void contextDestroyed(ServletContextEvent sce) {
TransactionConfigurator.unregisterMicroserviceResourceFactory("xa/bookingSystem");
TransactionConfigurator.unregisterMicroserviceResourceFactory("xa/letterWriter");
//dont do this here - see note in #contextInitialized
new UserTransactionManager().close();
}
示例15: close
import com.atomikos.icatch.jta.UserTransactionManager; //导入依赖的package包/类
@Override
public void close() {
UserTransactionManager utm = getTransactionManager();
try {
if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){
throw new RuntimeException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus());
}
Transaction tx = utm.getTransaction();
tx.delistResource(ms, ms.getUnderlyingConnection().wasExecuteSuccessful() ? XAResource.TMSUCCESS : XAResource.TMFAIL);
} catch (Exception e) {
throw new RuntimeException("Unable to delist resource from transaction", e);
}
}