Package org.mule.api.transaction

Examples of org.mule.api.transaction.Transaction


        }
    }

    public void suspendCurrentTransaction() throws TransactionException
    {
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        if (logger.isDebugEnabled())
        {
            logger.debug("Suspending " + tx);
        }

        tx.suspend();

        if (logger.isDebugEnabled())
        {
            logger.debug("Successfully suspended " + tx);
            logger.debug("Unbinding the following TX from the current context: " + tx);
View Full Code Here


        suspendedTransaction.set(tx);
    }

    public void resumeSuspendedTransaction() throws TransactionException
    {
        Transaction tx = suspendedTransaction.get();
        if (logger.isDebugEnabled())
        {
            logger.debug("Re-binding and Resuming " + tx);
        }
        TransactionCoordination.getInstance().bindTransaction(tx);
        suspendedTransaction.remove();
        tx.resume();
    }
View Full Code Here

        isolatedTransactions.remove();
    }

    public void isolateTransaction()
    {
        Transaction currentTransaction = transactions.get();
        if (currentTransaction != null)
        {
            if (isolatedTransactions.get() == null)
            {
                isolatedTransactions.set(new ArrayStack());
View Full Code Here

    protected MessagingExceptionHandler mockMessagingExceptionHandler;

    @Before
    public void unbindTransaction() throws Exception
    {
        Transaction currentTransaction = TransactionCoordination.getInstance().getTransaction();
        if (currentTransaction != null)
        {
            TransactionCoordination.getInstance().unbindTransaction(currentTransaction);
        }
        when(mockMessagingException.getStackTrace()).thenReturn(new StackTraceElement[0]);
View Full Code Here

        TransactionCoordination.getInstance().bindTransaction(mockTransaction);
        MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_NONE);
        config.setInteractWithExternal(true);
        mockExternalTransactionFactory = mock(ExternalTransactionAwareTransactionFactory.class);
        config.setFactory(mockExternalTransactionFactory);
        Transaction externalTransaction = mock(Transaction.class);
        when(mockExternalTransactionFactory.joinExternalTransaction(mockMuleContext)).thenReturn(externalTransaction);
        ExecutionTemplate executionTemplate = createExecutionTemplate(config);
        Object result = executionTemplate.execute(getEmptyTransactionCallback());
        assertThat((MuleEvent) result, is(RETURN_VALUE));
        verify(mockTransaction).commit();
View Full Code Here

    {
        final CountDownLatch latch = new CountDownLatch(3);

        // the code is simple and deceptive :) The trick is this dummy transaction is handled by
        // a global TransactionCoordination instance, which binds it to the current thread.
        Transaction transaction = new DummyTransaction(muleContext);

        muleContext.registerListener(new TransactionNotificationListener<TransactionNotification>()
        {
            public void onNotification(TransactionNotification notification)
            {
                if (notification.getAction() == TransactionNotification.TRANSACTION_BEGAN)
                {
                    assertEquals("begin", notification.getActionName());
                    latch.countDown();
                }
                else
                {
                    if (notification.getAction() == TransactionNotification.TRANSACTION_COMMITTED)
                    {
                        assertEquals("commit", notification.getActionName());
                        latch.countDown();
                    }
                    else
                    {
                        if (notification.getAction() == TransactionNotification.TRANSACTION_ROLLEDBACK)
                        {
                            assertEquals("rollback", notification.getActionName());
                            latch.countDown();
                        }
                    }
                }
            }
        }, transaction.getId());


        transaction.begin();
        transaction.commit();
        transaction.rollback();

        // Wait for the notifcation event to be fired as they are queued
        latch.await(2000, TimeUnit.MILLISECONDS);
        assertEquals("There are still some notifications left unfired.", 0, latch.getCount());
    }
View Full Code Here

    }

    @Override
    public T execute(ExecutionCallback<T> callback) throws Exception
    {
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        if (transactionConfig.getAction() == TransactionConfig.ACTION_NEVER && tx != null)
        {
            throw new IllegalTransactionStateException(
                    CoreMessages.transactionAvailableButActionIs("Never"));
        } else if (transactionConfig.getAction() == TransactionConfig.ACTION_ALWAYS_JOIN && tx == null)
View Full Code Here

    }

    @Override
    public T execute(ExecutionCallback<T> callback) throws Exception
    {
        Transaction suspendedXATx = null;
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        byte action = transactionConfig.getAction();
        if ((action == TransactionConfig.ACTION_NONE || action == TransactionConfig.ACTION_ALWAYS_BEGIN)
                && tx != null && tx.isXA())
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("suspending XA tx " + action + ", " + "current TX: " + tx);
            }
View Full Code Here

        boolean transactionIsolated = false;
        try
        {
            if (transactionConfig.getAction() == TransactionConfig.ACTION_NOT_SUPPORTED)
            {
                Transaction transaction = TransactionCoordination.getInstance().getTransaction();
                if (transaction != null)
                {
                    TransactionCoordination.getInstance().isolateTransaction();
                    transactionIsolated = true;
                }
View Full Code Here

    }

    @Override
    public T execute(ExecutionCallback<T> callback) throws Exception
    {
        Transaction joinedExternal = null;
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        try
        {
            if (tx == null && muleContext != null && transactionConfig != null && transactionConfig.isInteractWithExternal())
            {
View Full Code Here

TOP

Related Classes of org.mule.api.transaction.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.