本文整理了Java中bitronix.tm.BitronixTransactionManager.rollback()
方法的一些代码示例,展示了BitronixTransactionManager.rollback()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitronixTransactionManager.rollback()
方法的具体详情如下:
包路径:bitronix.tm.BitronixTransactionManager
类名称:BitronixTransactionManager
方法名:rollback
暂无
代码示例来源:origin: ehcache/ehcache3
public static void testXmlConfiguration() throws Exception {
BitronixTransactionManager transactiOnManager= getTransactionManager();
try (CacheManager cacheManager = newCacheManager(
new XmlConfiguration(TestMethods.class.getResource("ehcache-xa-osgi.xml"), TestMethods.class.getClassLoader())
)) {
cacheManager.init();
Cache
transactionManager.begin();
try {
xaCache.put(1L, "one");
} catch (Throwable t) {
transactionManager.rollback();
}
transactionManager.commit();
}
transactionManager.shutdown();
}
}
代码示例来源:origin: ehcache/ehcache3
public static void testProgrammaticConfiguration() throws Exception {
BitronixTransactionManager transactiOnManager= getTransactionManager();
try (CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.withClassLoader(TestMethods.class.getClassLoader())
.using(new LookupTransactionManagerProviderConfiguration(BitronixTransactionManagerLookup.class))
.withCache("xaCache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10))
.add(new XAStoreConfiguration("xaCache")).build()).build(true)) {
Cache
transactionManager.begin();
try {
xaCache.put(1L, "one");
} catch (Throwable t) {
transactionManager.rollback();
}
transactionManager.commit();
}
transactionManager.shutdown();
}
代码示例来源:origin: org.jbpm/droolsjbpm-knowledge-services
public void rollback() throws IllegalStateException, SecurityException, SystemException {
try {
btm.rollback();
} finally {
getSynchronizations().afterTransactionCompletion(false);
}
}
代码示例来源:origin: bitronix/btm
public void testSuspendResume() throws Exception {
log.info("test starts");
btm.begin();
log.info("tx begun");
Transaction tx = btm.suspend();
log.info("tx suspended");
btm.resume(tx);
log.info("tx resumed");
btm.rollback();
log.info("test over");
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
public void testSuspendResume() throws Exception {
log.info("test starts");
btm.begin();
log.info("tx begun");
Transaction tx = btm.suspend();
log.info("tx suspended");
btm.resume(tx);
log.info("tx resumed");
btm.rollback();
log.info("test over");
}
代码示例来源:origin: bitronix/btm
protected void tearDown() throws Exception {
if (btm.getStatus() != Status.STATUS_NO_TRANSACTION)
btm.rollback();
btm.shutdown();
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
protected void tearDown() throws Exception {
if (btm.getStatus() != Status.STATUS_NO_TRANSACTION)
btm.rollback();
btm.shutdown();
}
代码示例来源:origin: bitronix/btm
@Override
protected void tearDown() throws Exception {
try {
if (log.isDebugEnabled()) { log.debug("*** tearDown rollback"); }
TransactionManagerServices.getTransactionManager().rollback();
} catch (Exception ex) {
// ignore
}
poolingDataSource1.close();
poolingDataSource2.close();
TransactionManagerServices.getTransactionManager().shutdown();
}
代码示例来源:origin: bitronix/btm
@Override
protected void tearDown() throws Exception {
try {
if (log.isDebugEnabled()) { log.debug("*** tearDown rollback"); }
TransactionManagerServices.getTransactionManager().rollback();
} catch (Exception ex) {
// ignore
}
poolingConnectionFactory1.close();
poolingConnectionFactory2.close();
TransactionManagerServices.getTransactionManager().shutdown();
}
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
@Override
protected void tearDown() throws Exception {
try {
if (log.isDebugEnabled()) { log.debug("*** tearDown rollback"); }
TransactionManagerServices.getTransactionManager().rollback();
} catch (Exception ex) {
// ignore
}
poolingDataSource1.close();
poolingDataSource2.close();
TransactionManagerServices.getTransactionManager().shutdown();
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
@Override
protected void tearDown() throws Exception {
try {
if (log.isDebugEnabled()) { log.debug("*** tearDown rollback"); }
TransactionManagerServices.getTransactionManager().rollback();
} catch (Exception ex) {
// ignore
}
poolingConnectionFactory1.close();
poolingConnectionFactory2.close();
TransactionManagerServices.getTransactionManager().shutdown();
}
}
代码示例来源:origin: bitronix/btm
public void testEagerEnding() throws Exception {
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
try {
tm.rollback();
fail("TM allowed rollback with no TX started");
} catch (IllegalStateException ex) {
assertEquals("no transaction started on this thread", ex.getMessage());
}
try {
tm.commit();
fail("TM allowed commit with no TX started");
} catch (IllegalStateException ex) {
assertEquals("no transaction started on this thread", ex.getMessage());
}
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
public void testEagerEnding() throws Exception {
BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();
try {
tm.rollback();
fail("TM allowed rollback with no TX started");
} catch (IllegalStateException ex) {
assertEquals("no transaction started on this thread", ex.getMessage());
}
try {
tm.commit();
fail("TM allowed commit with no TX started");
} catch (IllegalStateException ex) {
assertEquals("no transaction started on this thread", ex.getMessage());
}
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
tm.rollback();
if (log.isDebugEnabled()) { log.debug("*** TX is done"); }
代码示例来源:origin: bitronix/btm
public void testTransactionManagerGetTransaction() throws Exception {
assertNull(btm.getTransaction());
btm.begin();
assertNotNull(btm.getTransaction());
btm.commit();
assertNull(btm.getTransaction());
btm.begin();
assertNotNull(btm.getTransaction());
btm.rollback();
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
public void testTransactionManagerGetTransaction() throws Exception {
assertNull(btm.getTransaction());
btm.begin();
assertNotNull(btm.getTransaction());
btm.commit();
assertNull(btm.getTransaction());
btm.begin();
assertNotNull(btm.getTransaction());
btm.rollback();
}
代码示例来源:origin: bitronix/btm
public void testSkipInFlightCommit() throws Exception {
BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();
Uid uid0 = UidGenerator.generateUid();
Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid0);
Set
names.add(pds.getUniqueName());
journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);
assertNull(btm.getCurrentTransaction());
Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
btm.begin();
Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid1);
names = new HashSet
names.add(pds.getUniqueName());
journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names);
TransactionManagerServices.getRecoverer().run();
btm.rollback();
assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
btm.shutdown();
TransactionManagerServices.getJournal().open();
TransactionManagerServices.getRecoverer().run();
assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
public void testSkipInFlightCommit() throws Exception {
BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();
Uid uid0 = UidGenerator.generateUid();
Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid0);
Set
names.add(pds.getUniqueName());
journal.log(Status.STATUS_COMMITTING, new Uid(xid0.getGlobalTransactionId()), names);
assertNull(btm.getCurrentTransaction());
Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
btm.begin();
Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid1);
names = new HashSet
names.add(pds.getUniqueName());
journal.log(Status.STATUS_COMMITTING, new Uid(xid1.getGlobalTransactionId()), names);
TransactionManagerServices.getRecoverer().run();
btm.rollback();
assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
btm.shutdown();
TransactionManagerServices.getJournal().open();
TransactionManagerServices.getRecoverer().run();
assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
}
代码示例来源:origin: bitronix/btm
public void testSkipInFlightRollback() throws Exception {
BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();
Uid uid0 = UidGenerator.generateUid();
Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid0);
assertNull(btm.getCurrentTransaction());
Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
btm.begin();
Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid1);
TransactionManagerServices.getRecoverer().run();
btm.rollback();
assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount());
assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount());
assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
btm.shutdown();
TransactionManagerServices.getJournal().open();
TransactionManagerServices.getRecoverer().run();
assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount());
assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount());
assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
}
代码示例来源:origin: com.github.marcus-nl.btm/btm
public void testSkipInFlightRollback() throws Exception {
BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();
Uid uid0 = UidGenerator.generateUid();
Xid xid0 = new MockXid(0, uid0.getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid0);
assertNull(btm.getCurrentTransaction());
Thread.sleep(30); // let the clock run a bit so that in-flight TX is a bit older than the journaled one
btm.begin();
Xid xid1 = new MockXid(1, UidGenerator.generateUid().getArray(), BitronixXid.FORMAT_ID);
xaResource.addInDoubtXid(xid1);
TransactionManagerServices.getRecoverer().run();
btm.rollback();
assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount());
assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount());
assertEquals(1, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
btm.shutdown();
TransactionManagerServices.getJournal().open();
TransactionManagerServices.getRecoverer().run();
assertEquals(0, TransactionManagerServices.getRecoverer().getCommittedCount());
assertEquals(1, TransactionManagerServices.getRecoverer().getRolledbackCount());
assertEquals(0, xaResource.recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN).length);
}