Package org.apache.activemq.transaction

Examples of org.apache.activemq.transaction.Transaction


    //
    //////////////////////////////////////////////////////////////////////////////
    public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception {
        ArrayList txs = new ArrayList();
        for (Iterator iter = xaTransactions.values().iterator(); iter.hasNext();) {
            Transaction tx = (Transaction) iter.next();
            if( tx.isPrepared() )
                txs.add(tx.getTransactionId());
        }
        XATransactionId rc[] = new XATransactionId[txs.size()];
        txs.toArray(rc);
        return rc;
    }
View Full Code Here


    public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception {
       
        // the transaction may have already been started.
        if( xid.isXATransaction() ) {
            Transaction transaction = (Transaction)xaTransactions.get(xid);
            if( transaction != null  )
                return;
            transaction = new XATransaction(transactionStore, (XATransactionId)xid, this);
            xaTransactions.put(xid, transaction);
        } else {
            Map transactionMap = context.getTransactions();       
            Transaction transaction = (Transaction)transactionMap.get(xid);
            if( transaction != null  )
                throw new JMSException("Transaction '"+xid+"' has already been started.");
           
            transaction = new LocalTransaction(transactionStore, (LocalTransactionId)xid, context);
            transactionMap.put(xid, transaction);
View Full Code Here

            transactionMap.put(xid, transaction);
        }
    }

    public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception {
        Transaction transaction = getTransaction(context, xid, false);
        return transaction.prepare();
    }
View Full Code Here

        Transaction transaction = getTransaction(context, xid, false);
        return transaction.prepare();
    }
   
    public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception {
        Transaction transaction = getTransaction(context, xid, true);
        transaction.commit(onePhase);
    }
View Full Code Here

        Transaction transaction = getTransaction(context, xid, true);
        transaction.commit(onePhase);
    }

    public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception {
        Transaction transaction = getTransaction(context, xid, true);
        transaction.rollback();
    }
View Full Code Here

        Transaction transaction = getTransaction(context, xid, true);
        transaction.rollback();
    }
   
    public void forgetTransaction(ConnectionContext context, TransactionId xid) throws Exception {
        Transaction transaction = getTransaction(context, xid, true);
        transaction.rollback();
    }
View Full Code Here

    }
   
    public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
        // This method may be invoked recursively. 
        // Track original tx so that it can be restored.
        Transaction originalTx = context.getTransaction();
        Transaction transaction=null;
        if( ack.isInTransaction() ) {
            transaction = getTransaction(context, ack.getTransactionId(), false);
        }
        context.setTransaction(transaction);
        try {
View Full Code Here

    }
   
    public void send(ConnectionContext context, Message message) throws Exception {
        // This method may be invoked recursively. 
        // Track original tx so that it can be restored.
        Transaction originalTx = context.getTransaction();
        Transaction transaction=null;
        if( message.getTransactionId()!=null ) {
            transaction = getTransaction(context, message.getTransactionId(), false);
        }
        context.setTransaction(transaction);
        try {
View Full Code Here

    }
   
    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
        for (Iterator iter = context.getTransactions().values().iterator(); iter.hasNext();) {
            try {
                Transaction transaction = (Transaction) iter.next();
                transaction.rollback();           
            }
            catch (Exception e) {
                log.warn("ERROR Rolling back disconnected client's transactions: ", e);
            }
            iter.remove();
View Full Code Here

    // Implementation help methods.
    //
    //////////////////////////////////////////////////////////////////////////////
    public Transaction getTransaction(ConnectionContext context, TransactionId xid, boolean mightBePrepared) throws JMSException, XAException {
        Map transactionMap = xid.isXATransaction() ? xaTransactions : context.getTransactions();       
        Transaction transaction = (Transaction)transactionMap.get(xid);

        if( transaction != null  )
            return transaction;
       
        if( xid.isXATransaction() ) {
View Full Code Here

TOP

Related Classes of org.apache.activemq.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.