@Override public void setTransactionTimeout(int timeout) throws SystemException { this.transactionManager.setTransactionTimeout(timeout); }
/** {@inheritDoc} */ @Override public void setTransactionTimeout(int seconds) throws SystemException { mgr.setTransactionTimeout(seconds); }
@Override public void setTransactionTimeout(int timeout) throws SystemException { this.transactionManager.setTransactionTimeout(timeout); }
@Override public Transaction createTransaction(@Nullable String name, int timeout) throws NotSupportedException, SystemException { if (timeout >= 0) { this.transactionManager.setTransactionTimeout(timeout); } this.transactionManager.begin(); return new ManagedTransactionAdapter(this.transactionManager); }
@Override public Transaction createTransaction(@Nullable String name, int timeout) throws NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); Assert.state(tm != null, "No JTA TransactionManager available"); if (timeout >= 0) { tm.setTransactionTimeout(timeout); } tm.begin(); return new ManagedTransactionAdapter(tm); }
@Override public Transaction createTransaction(@Nullable String name, int timeout) throws NotSupportedException, SystemException { if (timeout >= 0) { this.transactionManager.setTransactionTimeout(timeout); } this.transactionManager.begin(); return new ManagedTransactionAdapter(this.transactionManager); }
@Override public Transaction createTransaction(@Nullable String name, int timeout) throws NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); Assert.state(tm != null, "No JTA TransactionManager available"); if (timeout >= 0) { tm.setTransactionTimeout(timeout); } tm.begin(); return new ManagedTransactionAdapter(tm); }
/** * Calls begin() of the transaction manager owning this user transaction * * @see javax.transaction.UserTransaction#begin() */ @Override public synchronized void begin() throws NotSupportedException, SystemException { LogWriter log = InternalDistributedSystem.getLogger(); if (log.fineEnabled()) { log.fine("UserTransactionImpl starting JTA transaction"); } int temp = storedTimeOut; storedTimeOut = TransactionManagerImpl.DEFAULT_TRANSACTION_TIMEOUT; tm.begin(); tm.setTransactionTimeout(temp); }
/** * Checks if transaction has begun. If yes, then call the tm.setTransactionTimeOut else stores and * * @see javax.transaction.UserTransaction#setTransactionTimeout */ @Override public void setTransactionTimeout(int timeOut) throws SystemException { if (timeOut < 0) { String exception = "Cannot set a negative Time Out for transactions"; LogWriter writer = TransactionUtils.getLogWriter(); if (writer.fineEnabled()) writer.fine(exception); throw new SystemException(exception); } else if (timeOut == 0) { timeOut = TransactionManagerImpl.DEFAULT_TRANSACTION_TIMEOUT; } if (tm.getTransaction() != null) { tm.setTransactionTimeout(timeOut); } else { storedTimeOut = timeOut; } } }
final TransactionManager tm = this.tm; final int oldTimeout = getTransactionManagerTimeout(); tm.setTransactionTimeout(timeout); try { final Transaction suspended = tm.suspend(); known.put(gtid, getEntryFor(transaction, gtid)); tm.setTransactionTimeout(oldTimeout); return transaction; } catch (NotSupportedException e) { tm.setTransactionTimeout(oldTimeout); } catch (Throwable t2) {
@Override public Object processInvocation(final InterceptorContext context) throws Exception { TransactionManager tm = component.getTransactionManager(); int oldTimeout = getCurrentTransactionTimeout(component); try { Transaction oldTx = tm.suspend(); try { return handleInvocation(context); } finally { if (oldTx != null) tm.resume(oldTx); } } finally { tm.setTransactionTimeout(oldTimeout == -1 ? 0 : oldTimeout); } }
public void testAuditProcessManagerFlushedOnTransactionTimeout() throws Exception { TestingJtaPlatformImpl.INSTANCE.getTransactionManager().setTransactionTimeout( 5 );
@Test public void testTxManagerCommitDissassociatesThread() throws Exception { // don't wait for ages, has to be set before TX is begun tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS); tm.begin(); Transaction tx = tm.getTransaction(); assertNotNull("Transaction should have started.", tx); assertEquals("TX should have been active", Status.STATUS_ACTIVE, tx.getStatus()); tm.commit(); assertNull("Committing via TX Manager should have disassociated TX from the current thread.", tm.getTransaction()); }
@Test public void testTxManagerRollbackDissassociatesThread() throws Exception { // don't wait for ages, has to be set before TX is begun tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS); tm.begin(); Transaction tx = tm.getTransaction(); assertNotNull("Transaction should have started.", tx); assertEquals("TX should have been active", Status.STATUS_ACTIVE, tx.getStatus()); tm.rollback(); assertNull("Committing via TX Manager should have disassociated TX from the current thread.", tm.getTransaction()); }
@Test public void setsTransactionTimeoutOnBegin() throws Exception { final int timeoutMillis = 5000; final int timeoutSecs = timeoutMillis / 1000; XaTransaction xaTransaction = new XaTransaction(mockMuleContext); xaTransaction.setTimeout(timeoutMillis); xaTransaction.begin(); final InOrder inOrder = inOrder(mockTransactionManager); inOrder.verify(mockTransactionManager).setTransactionTimeout(timeoutSecs); inOrder.verify(mockTransactionManager).begin(); } }
@Test public void testTxHandleCommitKeepsThreadAssociation() throws Exception { // don't wait for ages, has to be set before TX is begun tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS); tm.begin(); Transaction tx = tm.getTransaction(); assertNotNull("Transaction should have started.", tx); assertEquals("TX should have been active", Status.STATUS_ACTIVE, tx.getStatus()); tx.commit(); tx = tm.getTransaction(); assertNotNull("Committing via TX handle should NOT disassociated TX from the current thread.", tx); assertEquals("TX status should have been COMMITTED.", Status.STATUS_COMMITTED, tx.getStatus()); // Remove the TX-thread association. The only public API to achieve it is suspend(), // technically we never resume the same transaction (TX forget). Transaction suspended = tm.suspend(); assertTrue("Wrong TX suspended?.", suspended.equals(tx)); assertNull("TX should've been disassociated from the thread.", tm.getTransaction()); // should be no-op and never fail tm.resume(null); // ensure we don't have any TX-Thread association lurking around a main thread assertNull(tm.getTransaction()); }
/** * This is a former XaTransactionTestCase. * * @throws Exception in case of any error */ @Test public void testXaTransactionTermination() throws Exception { muleContext.setTransactionManager(tm); assertNull("There should be no current transaction associated.", tm.getTransaction()); // don't wait for ages, has to be set before TX is begun tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS); XaTransaction muleTx = new XaTransaction(muleContext); assertFalse(muleTx.isBegun()); assertEquals(Status.STATUS_NO_TRANSACTION, muleTx.getStatus()); muleTx.begin(); assertTrue(muleTx.isBegun()); muleTx.commit(); Transaction jtaTx = tm.getTransaction(); assertNull("Committing via TX Manager should have disassociated TX from the current thread.", jtaTx); assertEquals(Status.STATUS_NO_TRANSACTION, muleTx.getStatus()); }
tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS);
tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS);
tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS);