Package org.mule.api.transaction

Examples of org.mule.api.transaction.Transaction


        Destination replyTo = null;
        boolean transacted = false;
        boolean cached = false;
        boolean useReplyToDestination;

        final Transaction muleTx = TransactionCoordination.getInstance().getTransaction();

        if (logger.isDebugEnabled())
        {
            logger.debug("dispatching on endpoint: " + endpoint.getEndpointURI()
                    + ". MuleEvent id is: " + event.getId()
                    + ". Outbound transformers are: " + endpoint.getTransformers());
        }

        // assume session is transacted first, and thus, managed
        boolean sessionManaged = true;
        try
        {
            session = connector.getSessionFromTransaction();
            if (session != null)
            {
                transacted = true;
            }
            // Should we be caching sessions? Note this is not part of the JMS spec.
            // and is turned off by default.
            else if (event.getMessage().getOutboundProperty(JmsConstants.CACHE_JMS_SESSIONS_PROPERTY, connector.isCacheJmsSessions()))
            {
                sessionManaged = false;
                cached = true;
                if (cachedSession != null)
                {
                    session = cachedSession;
                }
                else
                {
                    session = connector.getSession(endpoint);
                    cachedSession = session;
                }
            }
            else
            {
                // by now we're running with a different connector and connection
                sessionManaged = muleTx != null && muleTx.isXA();

                session = connector.getSession(endpoint);
                if (endpoint.getTransactionConfig().isTransacted())
                {
                    transacted = true;
View Full Code Here


                {
                    // There is not a need to close resources here,
                    // they will be close by XaTransaction, 
                    JmsThreadContext ctx = context.getContext();
                    ctx.consumer = null;
                    Transaction tx = TransactionCoordination.getInstance().getTransaction();
                    if (ctx.session != null && tx instanceof XaTransaction.MuleXaObject)
                    {
                        if (ctx.session instanceof XaTransaction.MuleXaObject)
                        {
                            ((XaTransaction.MuleXaObject) ctx.session).setReuseObject(false);
View Full Code Here

    @Override
    protected List<MuleMessage> getMessages() throws Exception
    {
        Session session = this.connector.getSessionFromTransaction();
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        MessageConsumer consumer = createConsumer();

        // Retrieve message
        Message message = null;
        try
        {
            message = consumer.receive(timeout);
        }
        catch (JMSException e)
        {
            // If we're being disconnected, ignore the exception
            if (!this.isConnected())
            {
                // ignore
            }
            else
            {
                throw e;
            }
        }
       
        if (message == null)
        {
            if (tx != null)
            {
                tx.setRollbackOnly();
            }
            return null;
        }
        message = connector.preProcessMessage(message, session);
View Full Code Here

            {
                ctx = new JmsThreadContext();
            }
           
            Session session;
            Transaction tx = TransactionCoordination.getInstance().getTransaction();
            if (this.reuseSession && ctx.session != null)
            {
                session = ctx.session;
                tx.bindResource(this.connector.getConnection(), session);
            }
            else
            {
                session = this.connector.getSession(endpoint);
                if (session != null && tx != null)
View Full Code Here

        return transactions.get();
    }

    public void unbindTransaction(final Transaction transaction) throws TransactionException
    {
        Transaction oldTx = transactions.get();

        if (oldTx instanceof TransactionCollection)
        {
            // if there are more in-flight aggregated transactions, do nothing yet
            if (!((TransactionCollection) oldTx).getTxCollection().isEmpty())
            {
                return;
            }
        }

        try
        {
            if (oldTx != null && !oldTx.equals(transaction))
            {
                throw new IllegalTransactionStateException(CoreMessages.transactionCannotUnbind());
            }
        }
        finally
View Full Code Here

        }
    }

    public void bindTransaction(final Transaction transaction) throws TransactionException
    {
        Transaction oldTx = transactions.get();
        // special handling for transaction collection
        if (oldTx != null && !(oldTx instanceof TransactionCollection))
        {
            throw new IllegalTransactionStateException(CoreMessages.transactionAlreadyBound());
        }
View Full Code Here

    }

    public void testBindTransaction() throws Exception
    {
        assertNull(tc.getTransaction());
        Transaction tx = Mockito.mock(Transaction.class);

        tc.bindTransaction(tx);
        assertEquals(tx, tc.getTransaction());
        tc.unbindTransaction(tx);
    }
View Full Code Here

    }

    public void testBindTransactionWithAlreadyBound() throws Exception
    {
        assertNull(tc.getTransaction());
        Transaction tx = Mockito.mock(Transaction.class);

        tc.bindTransaction(tx);
        assertEquals(tx, tc.getTransaction());

        try
        {
            Transaction tx2 = Mockito.mock(Transaction.class);
            tc.bindTransaction(tx2);
            fail();
        }
        catch (IllegalTransactionStateException e)
        {
View Full Code Here

    }

    public void testUnbindTransactionWithoutBound() throws Exception
    {
        assertNull(tc.getTransaction());
        Transaction tx = Mockito.mock(Transaction.class);

        tc.unbindTransaction(tx);
    }
View Full Code Here

    }

    public void testSetInstanceWithBound() throws Exception
    {
        assertNull(tc.getTransaction());
        Transaction tx = Mockito.mock(Transaction.class);

        tc.bindTransaction(tx);

        tc.unbindTransaction(tx);
    }
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.