Package org.apache.activemq.transaction

Examples of org.apache.activemq.transaction.Transaction


        }
    }

    // called while holding the sendLock
    private void registerSendSync(Message message, ConnectionContext context) {
        final Transaction transaction = context.getTransaction();
        Queue.SendSync currentSync = sendSyncs.get(transaction);
        if (currentSync == null) {
            currentSync = new Queue.SendSync(transaction);
            transaction.addSynchronization(currentSync);
            sendSyncs.put(transaction, currentSync);
        }
        currentSync.add(context, message);
    }
View Full Code Here


        @Override
        public void afterCommit() throws Exception {
            LinkedList<Transaction> orderedWork = new LinkedList<Transaction>();;
            // use existing object to sync orderIndexUpdates that can be reassigned
            synchronized (sendLock) {
                Transaction next = orderIndexUpdates.peek();
                while( next!=null && next.isCommitted() ) {
                    orderedWork.addLast(orderIndexUpdates.removeFirst());
                    next = orderIndexUpdates.peek();
                }
            }
            // do the ordered work
View Full Code Here

        }
    }

    // called while holding the sendLock
    private void registerSendSync(Message message, ConnectionContext context) {
        final Transaction transaction =
                message.isInTransaction() ? context.getTransaction()
                        : new OrderedNonTransactionWorkTx();
        Queue.SendSync currentSync = sendSyncs.get(transaction);
        if (currentSync == null) {
            currentSync = new Queue.SendSync(transaction);
            transaction.addSynchronization(currentSync);
            sendSyncs.put(transaction, currentSync);
        }
        currentSync.add(context, message);
    }
View Full Code Here

        public void afterCommit() throws Exception {
            ArrayList<SendSync> syncs = new ArrayList<SendSync>(200);
            sendLock.lockInterruptibly();
            try {
                synchronized (orderIndexUpdates) {
                    Transaction next = orderIndexUpdates.peek();
                    while( next!=null && next.isCommitted() ) {
                        syncs.add(sendSyncs.remove(orderIndexUpdates.removeFirst()));
                        next = orderIndexUpdates.peek();
                    }
                }
                for (SendSync sync : syncs) {
View Full Code Here

    // ////////////////////////////////////////////////////////////////////////////
    public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception {
        List<TransactionId> txs = new ArrayList<TransactionId>();
        synchronized (xaTransactions) {
            for (Iterator<Transaction> iter = xaTransactions.values().iterator(); iter.hasNext();) {
                Transaction tx = iter.next();
                if (tx.isPrepared()) {
                    txs.add(tx.getTransactionId());
                }
            }
        }
        XATransactionId rc[] = new XATransactionId[txs.size()];
        txs.toArray(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 = null;
            synchronized (xaTransactions) {
                transaction = xaTransactions.get(xid);
                if (transaction != null) {
                    return;
                }
                transaction = new XATransaction(transactionStore, (XATransactionId)xid, this);
                xaTransactions.put(xid, transaction);
            }
        } else {
            Map<TransactionId, Transaction> transactionMap = context.getTransactions();
            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

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.