@Override public boolean enlistResource(XAResource xaRes) throws RollbackException, SystemException { return this.transactionManager.getTransaction().enlistResource(xaRes); }
public void beginTransaction() throws Exception { if (transactionFactory != null && this.xaResource != null) { this.transaction = transactionFactory.createTransaction(transactionName, transactionTimeout); this.transaction.enlistResource(this.xaResource); } }
@Override public boolean enlistResource(XAResource xaRes) throws RollbackException, SystemException { return this.transactionManager.getTransaction().enlistResource(xaRes); }
@Override @SneakyThrows public void enlistResource(final SingleXAResource xaResource) { transactionManager.getTransaction().enlistResource(xaResource); }
/** {@inheritDoc} */ @Override public boolean enlistResource(final XAResource xaRes) throws RollbackException, IllegalStateException, SystemException { if (xaRes == null) return false; // final XAResource res = new IgniteOnePhaseXAResource(xaRes); Object ibmProxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {onePhaseXAResourceCls}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable { return mtd.invoke(xaRes, args); } }); return tx.enlistResource((XAResource)ibmProxy); }
public void beginTransaction() throws Exception { if (transactionFactory != null && this.xaResource != null) { this.transaction = transactionFactory.createTransaction(transactionName, transactionTimeout); this.transaction.enlistResource(this.xaResource); } }
void registerTranxConnection(XAConnection xaConn) throws Exception { try { synchronized (this) { if (transManager == null) { transManager = JNDIInvoker.getTransactionManager(); } } Transaction txn = transManager.getTransaction(); if (txn != null) { XAResource xar = xaConn.getXAResource(); txn.enlistResource(xar); // Add in the Map after successful registration of XAResource this.xaResourcesMap.put(xaConn, xar); } } catch (Exception ex) { Exception e = new Exception( String.format( "GemFireTransactionDataSource-registerTranxConnection(). Exception in registering the XAResource with the Transaction.Exception occurred= %s", ex)); e.initCause(ex); throw e; } }
public boolean enlistResource(final XAResource xaRes) throws RollbackException, IllegalStateException, SystemException { Assert.checkNotNullParam("xaRes", xaRes); final int estimatedRemainingTime = max(1, getEstimatedRemainingTime()); try { xaRes.setTransactionTimeout(estimatedRemainingTime); } catch (XAException e) { throw Log.log.setTimeoutFailed(estimatedRemainingTime, e); } return transaction.enlistResource(xaRes); }
@Override public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException { // JCA 1.6 FR 13.5.6 // The application server must set the thread context class loader to the endpoint // application class loader during the beforeDelivery call. previousClassLoader = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(getApplicationClassLoader()); try { final TransactionManager tm = getTransactionManager(); // TODO: in violation of JCA 1.6 FR 13.5.9? previousTx = tm.suspend(); boolean isTransacted = service.isDeliveryTransacted(method); if (isTransacted) { tm.begin(); currentTx = tm.getTransaction(); if (xaRes != null) currentTx.enlistResource(xaRes); } } catch (Throwable t) { throw new ApplicationServerInternalException(t); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(previousClassLoader); } }
@Override public Connection getConnection() throws SQLException { Transaction currentTransaction = findCurrentTransaction(); try { if ( currentTransaction == null ) { // this block handles non enlisted connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connection connection = delegate.getConnection(); nonEnlistedConnections.add( connection ); return connection; } // this portion handles enlisted connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connection connection = (Connection) TestingJtaPlatformImpl.synchronizationRegistry().getResource( CONNECTION_KEY ); if ( connection == null ) { connection = delegate.getConnection(); TestingJtaPlatformImpl.synchronizationRegistry().putResource( CONNECTION_KEY, connection ); XAResourceWrapper xaResourceWrapper = new XAResourceWrapper( this, connection ); currentTransaction.enlistResource( xaResourceWrapper ); } return connection; } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e); } }
xaResource = new EhcacheXAResource<>(underlyingStore, journal, transactionContextFactory); transactionManagerWrapper.registerXAResource(uniqueXAResourceId, xaResource); transactionManagerWrapper.getTransactionManager().getTransaction().enlistResource(xaResource); xaResources.put(transaction, xaResource); final EhcacheXAResource<K, V> finalXaResource = xaResource;
txn.enlistResource(xar); java.util.List resList = (List) xalistThreadLocal.get(); if (resList.size() == 0) {
txn.enlistResource(xar);
else if (!jtaTx.enlistResource(rsrc)) throw new IgniteCheckedException("Failed to enlist XA resource to JTA user transaction.");
/** * {@inheritDoc} */ public XATransactionContext createTransactionContext() throws SystemException, RollbackException { XATransactionContext ctx = getCurrentTransactionContext(); if (ctx != null) { return ctx; } Transaction transaction = txnManager.getTransaction(); LOG.debug("enlisting {} in {}", this, transaction); transaction.enlistResource(this); // currentXid is set by a call to start() which itself is called by transaction.enlistResource(this) if (currentXid == null) { throw new CacheException("enlistment of XAResource of cache named '" + getCacheName() + "' did not end up calling XAResource.start()"); } ctx = xidToContextMap.get(currentXid); if (ctx == null) { LOG.debug("creating new context for XID [{}]", currentXid); ctx = new XATransactionContext(underlyingStore); xidToContextMap.put(currentXid, ctx); } return ctx; }
transactionController.getCurrentTransactionContext().getTransactionId(), transactionManagerLookup); transactionManagerLookup.register(xaRes, false); tx.enlistResource(xaRes); } else { tx.registerSynchronization(new JtaLocalEhcacheSynchronization(transactionController,
@Override public void register(TransactionManager transactionManager) throws Exception { Transaction transaction = transactionManager.getTransaction(); transaction.enlistResource(new FailXaResource(failMode)); } }
protected void startTx() throws Exception { tm(cache).begin(); cache.put(key(), "value"); tx = tm(cache).getTransaction(); tx.enlistResource(new XAResourceAdapter()); // this is to force 2PC and to prevent transaction managers attempting to optimise the call to a 1PC. txsStarted.countDown(); }
public void testCommit() throws Exception { assertCommitRollback(0, 0, txInterceptor); tm.begin(); //enlist another resource adapter to force TM to execute 2PC (otherwise 1PC) tm.getTransaction().enlistResource(new XAResourceAdapter()); assertCommitRollback(0, 0, txInterceptor); cache1.put("key", "value"); assertCommitRollback(0, 0, txInterceptor); tm.commit(); assertCommitRollback(1, 0, txInterceptor); }
public void testRemoteCommit() throws Exception { assertCommitRollback(0, 0, txInterceptor2); tm.begin(); assertCommitRollback(0, 0, txInterceptor2); //enlist another resource adapter to force TM to execute 2PC (otherwise 1PC) tm.getTransaction().enlistResource(new XAResourceAdapter()); cache2.put("key", "value"); assertCommitRollback(0, 0, txInterceptor2); tm.commit(); assertCommitRollback(1, 0, txInterceptor2); }