private void safeSuspend(final Throwable t) { try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { t.addSuppressed(e); } }
private static SysExTry whileSuspended() throws SystemException { final ContextTransactionManager tm = ContextTransactionManager.INSTANCE; final AbstractTransaction suspended = tm.suspend(); return suspended == null ? AbstractTransaction::doNothing : () -> tm.resume(suspended); }
private void safeSuspend() { try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { throw new EJBException(e); } }
public Transaction getCurrentTransaction() { final LocalTransactionContext current = LocalTransactionContext.getCurrent(); try { current.importProviderTransaction(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to determine inbound transaction context", e); } try { return ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to suspend inbound transaction context", e); } } }
/** * <p> * Suspending transaction and canceling the work. * <p> * Suspend transaction has to be called on the wildfly transaction manager * and the we delegate work cancellation to {@link JBossXATerminator}.<br> * First we have to cancel the work for jboss terminator would not work with * suspended transaction. */ @Override public void endWork(Work work, Xid xid) { jbossXATerminator.cancelWork(work, xid); try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException se) { throw TransactionLogger.ROOT_LOGGER.cannotSuspendInflowTransactionUnexpectedError(work, se); } }
@Override public SessionID handleSessionCreation(EJBSessionCreationInvocationContext context) throws Exception { AbstractTransaction transaction = context.getTransaction(); // While session requests currently only utilize the caller thread, // this will support any future use of a worker. Additionally hides // TX from other interceptors, providing consistency with standard // invocation handling. if (transaction == null) { transaction = transactionManager.getTransaction(); context.setTransaction(transaction); } setupStickinessIfRequired(context, true, transaction); Transaction old = transactionManager.suspend(); try { return context.proceed(); } finally { transactionManager.resume(old); } }
public void handleInvocation(final EJBClientInvocationContext context) throws Exception { final ClientTransactionPolicy transactionPolicy = context.getTransactionPolicy(); AbstractTransaction transaction = context.getTransaction(); // Always prefer the context TX, as the caller TX might be wrong // (e.g. retries happen in worker thread, not caller thread) if (transaction == null) { transaction = transactionManager.getTransaction(); } setupStickinessIfRequired(context, transactionPolicy.propagate(), transaction); if (transactionPolicy.failIfTransactionAbsent()) { if (transaction == null) { throw Logs.TXN.txNotActiveForThread(); } } if (transactionPolicy.failIfTransactionPresent()) { if (transaction != null) { throw Logs.TXN.txAlreadyAssociatedWithThread(); } } if (transactionPolicy.propagate()) { context.setTransaction(transaction); } // Hide any caller TX from other interceptors Transaction old = transactionManager.suspend(); try { context.sendRequest(); } finally { transactionManager.resume(old); } }
tm.suspend(); // clear current tx state and throw EJBException throw EjbLogger.ROOT_LOGGER.transactionInUnexpectedState(tx, statusAsString(txStatus));
private static SysExTry whileSuspended() throws SystemException { final ContextTransactionManager tm = ContextTransactionManager.INSTANCE; final AbstractTransaction suspended = tm.suspend(); return suspended == null ? AbstractTransaction::doNothing : () -> tm.resume(suspended); }
private static SysExTry whileSuspended() throws SystemException { final ContextTransactionManager tm = ContextTransactionManager.INSTANCE; final AbstractTransaction suspended = tm.suspend(); return suspended == null ? AbstractTransaction::doNothing : () -> tm.resume(suspended); }
public Transaction getCurrentTransaction() { final LocalTransactionContext current = LocalTransactionContext.getCurrent(); try { current.importProviderTransaction(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to determine inbound transaction context", e); } try { return ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to suspend inbound transaction context", e); } } }
public Transaction getCurrentTransaction() { final LocalTransactionContext current = LocalTransactionContext.getCurrent(); try { current.importProviderTransaction(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to determine inbound transaction context", e); } try { return ContextTransactionManager.getInstance().suspend(); } catch (SystemException e) { throw new RuntimeException("InboundTransactionCurrentImpl unable to suspend inbound transaction context", e); } } }
/** * <p> * Suspending transaction and canceling the work. * <p> * Suspend transaction has to be called on the wildfly transaction manager * and the we delegate work cancellation to {@link JBossXATerminator}.<br> * First we have to cancel the work for jboss terminator would not work with * suspended transaction. */ @Override public void endWork(Work work, Xid xid) { jbossXATerminator.cancelWork(work, xid); try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException se) { throw TransactionLogger.ROOT_LOGGER.cannotSuspendInflowTransactionUnexpectedError(work, se); } }
/** * <p> * Suspending transaction and canceling the work. * <p> * Suspend transaction has to be called on the wildfly transaction manager * and the we delegate work cancellation to {@link JBossXATerminator}.<br> * First we have to cancel the work for jboss terminator would not work with * suspended transaction. */ @Override public void endWork(Work work, Xid xid) { jbossXATerminator.cancelWork(work, xid); try { ContextTransactionManager.getInstance().suspend(); } catch (SystemException se) { throw TransactionLogger.ROOT_LOGGER.cannotSuspendInflowTransactionUnexpectedError(work, se); } }
@Override public SessionID handleSessionCreation(EJBSessionCreationInvocationContext context) throws Exception { AbstractTransaction transaction = context.getTransaction(); // While session requests currently only utilize the caller thread, // this will support any future use of a worker. Additionally hides // TX from other interceptors, providing consistency with standard // invocation handling. if (transaction == null) { transaction = transactionManager.getTransaction(); context.setTransaction(transaction); } setupStickinessIfRequired(context, true, transaction); Transaction old = transactionManager.suspend(); try { return context.proceed(); } finally { transactionManager.resume(old); } }
@Override public SessionID handleSessionCreation(EJBSessionCreationInvocationContext context) throws Exception { AbstractTransaction transaction = context.getTransaction(); // While session requests currently only utilize the caller thread, // this will support any future use of a worker. Additionally hides // TX from other interceptors, providing consistency with standard // invocation handling. if (transaction == null) { transaction = transactionManager.getTransaction(); context.setTransaction(transaction); } setupStickinessIfRequired(context, true, transaction); Transaction old = transactionManager.suspend(); try { return context.proceed(); } finally { transactionManager.resume(old); } }
public void handleInvocation(final EJBClientInvocationContext context) throws Exception { final ClientTransactionPolicy transactionPolicy = context.getTransactionPolicy(); AbstractTransaction transaction = context.getTransaction(); // Always prefer the context TX, as the caller TX might be wrong // (e.g. retries happen in worker thread, not caller thread) if (transaction == null) { transaction = transactionManager.getTransaction(); } setupStickinessIfRequired(context, transactionPolicy.propagate(), transaction); if (transactionPolicy.failIfTransactionAbsent()) { if (transaction == null) { throw Logs.TXN.txNotActiveForThread(); } } if (transactionPolicy.failIfTransactionPresent()) { if (transaction != null) { throw Logs.TXN.txAlreadyAssociatedWithThread(); } } if (transactionPolicy.propagate()) { context.setTransaction(transaction); } // Hide any caller TX from other interceptors Transaction old = transactionManager.suspend(); try { context.sendRequest(); } finally { transactionManager.resume(old); } }
public void handleInvocation(final EJBClientInvocationContext context) throws Exception { final ClientTransactionPolicy transactionPolicy = context.getTransactionPolicy(); AbstractTransaction transaction = context.getTransaction(); // Always prefer the context TX, as the caller TX might be wrong // (e.g. retries happen in worker thread, not caller thread) if (transaction == null) { transaction = transactionManager.getTransaction(); } setupStickinessIfRequired(context, transactionPolicy.propagate(), transaction); if (transactionPolicy.failIfTransactionAbsent()) { if (transaction == null) { throw Logs.TXN.txNotActiveForThread(); } } if (transactionPolicy.failIfTransactionPresent()) { if (transaction != null) { throw Logs.TXN.txAlreadyAssociatedWithThread(); } } if (transactionPolicy.propagate()) { context.setTransaction(transaction); } // Hide any caller TX from other interceptors Transaction old = transactionManager.suspend(); try { context.sendRequest(); } finally { transactionManager.resume(old); } }