Package org.apache.activemq.transaction

Examples of org.apache.activemq.transaction.Transaction


    public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception {
        // This method may be invoked recursively.
        // Track original tx so that it can be restored.
        final ConnectionContext context = consumerExchange.getConnectionContext();
        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(ProducerBrokerExchange producerExchange, final Message message) throws Exception {
        // This method may be invoked recursively.
        // Track original tx so that it can be restored.
        final ConnectionContext context = producerExchange.getConnectionContext();
        Transaction originalTx = context.getTransaction();
        Transaction transaction = null;
        Synchronization sync = null;
        if (message.getTransactionId() != null) {
            transaction = getTransaction(context, message.getTransactionId(), false);
            if (transaction != null) {
                sync = new Synchronization() {

                    public void afterRollback() {
                        if (audit != null) {
                            audit.rollback(message);
                        }
                    }
                };
                transaction.addSynchronization(sync);
            }
        }
        if (audit == null || !audit.isDuplicate(message)) {
            context.setTransaction(transaction);
            try {
                next.send(producerExchange, message);
            } finally {
                context.setTransaction(originalTx);
            }
        } else {
            if (sync != null && transaction != null) {
                transaction.removeSynchronization(sync);
            }
            LOG.debug("IGNORING duplicate message {}", message);
        }
    }
View Full Code Here

    }

    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
        for (Iterator<Transaction> iter = context.getTransactions().values().iterator(); iter.hasNext();) {
            try {
                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

    public Transaction getTransaction(ConnectionContext context, TransactionId xid, boolean mightBePrepared) throws JMSException, XAException {
        Map transactionMap = null;
        synchronized (xaTransactions) {
            transactionMap = xid.isXATransaction() ? xaTransactions : context.getTransactions();
        }
        Transaction transaction = (Transaction)transactionMap.get(xid);
        if (transaction != null) {
            return transaction;
        }
        if (xid.isXATransaction()) {
            XAException e = new XAException("Transaction '" + xid + "' has not been started.");
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

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.