Package org.codehaus.activemq.service

Examples of org.codehaus.activemq.service.Transaction


            while (rs.next()) {
                String id = rs.getString(1);
                byte data[] = this.getBinaryData(rs, 2);
                try {
                    ActiveMQXid xid = new ActiveMQXid(id);
                    Transaction transaction = XATransactionCommand.fromBytes(data);
                    transactionManager.loadTransaction(xid, transaction);
                }
                catch (Exception e) {
                    log.error("Failed to recover prepared transaction due to invalid xid: " + id, e);
                }
View Full Code Here


    /**
     * send a message to the broker within a transaction
     */
    public void sendTransactedMessage(final BrokerClient client, final String transactionId, final ActiveMQMessage message) throws JMSException {
        Transaction transaction;
        if (message.isXaTransacted()) {
            try {
                transaction = transactionManager.getXATransaction(new ActiveMQXid(transactionId));
            }
            catch (XAException e) {
                throw (JMSException) new JMSException(e.getMessage()).initCause(e);
            }
        }
        else {
            transaction = transactionManager.getLocalTransaction(transactionId);
        }

        transaction.addPostCommitTask(new SendMessageTransactionTask(client, message));
    }
View Full Code Here

    /**
     * Acknowledge consumption of a message within a transaction
     */
    public void acknowledgeTransactedMessage(final BrokerClient client, final String transactionId, final MessageAck ack) throws JMSException {
        Transaction transaction;
        if (ack.isXaTransacted()) {
            try {
                transaction = transactionManager.getXATransaction(new ActiveMQXid(transactionId));
            }
            catch (XAException e) {
                throw (JMSException) new JMSException(e.getMessage()).initCause(e);
            }
        }
        else {
            transaction = transactionManager.getLocalTransaction(transactionId);
        }
        transaction.addPostCommitTask(new MessageAckTransactionTask(client, ack));
        transaction.addPostRollbackTask(new RedeliverMessageTransactionTask(client, ack));

        // we need to tell the dispatcher that we can now accept another message
        // even though we don't really ack the message until the commit
        // this is because if we have a prefetch value of 1, we can never consume 2 messages
        // in a transaction, since the ack for the first message never arrives until the commit
View Full Code Here

    public void commitTransaction(BrokerClient client, String transactionId) throws JMSException {
        try {
            for (int i = 0; i < containerManagers.length; i++) {
                containerManagers[i].commitTransaction(client, transactionId);
            }
            Transaction transaction = transactionManager.getLocalTransaction(transactionId);
            transaction.commit(true);
        }
        catch (XAException e) {
            // TODO: I think the XAException should propagate all the way to the client.
            throw (JMSException) new JMSException(e.getMessage()).initCause(e);
        }
View Full Code Here

    public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException {
        try {
            for (int i = 0; i < containerManagers.length; i++) {
                containerManagers[i].rollbackTransaction(client, transactionId);
            }
            Transaction transaction = transactionManager.getLocalTransaction(transactionId);
            transaction.rollback();
        }
        catch (XAException e) {
            // TODO: I think the XAException should propagate all the way to the client.
            throw (JMSException) new JMSException(e.getMessage()).initCause(e);
        }
View Full Code Here

     * Prepares an XA Transaciton.
     *
     * @see org.codehaus.activemq.broker.Broker#prepareTransaction(org.codehaus.activemq.broker.BrokerClient, org.codehaus.activemq.message.ActiveMQXid)
     */
    public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException {
        Transaction transaction = transactionManager.getXATransaction(xid);
        return transaction.prepare();
    }
View Full Code Here

     * Rollback an XA Transaction.
     *
     * @see org.codehaus.activemq.broker.Broker#rollbackTransaction(org.codehaus.activemq.broker.BrokerClient, org.codehaus.activemq.message.ActiveMQXid)
     */
    public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException {
        Transaction transaction = transactionManager.getXATransaction(xid);
        transaction.rollback();
    }
View Full Code Here

     * Commit an XA Transaction.
     *
     * @see org.codehaus.activemq.broker.Broker#commitTransaction(org.codehaus.activemq.broker.BrokerClient, org.codehaus.activemq.message.ActiveMQXid, boolean)
     */
    public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException {
        Transaction transaction = transactionManager.getXATransaction(xid);
        transaction.commit(onePhase);
    }
View Full Code Here

    /**
     * @see org.codehaus.activemq.service.TransactionManager#getLocalTransaction(String)
     */
    public Transaction getLocalTransaction(String txid) throws JMSException {
        Transaction tx = (Transaction) localTxs.get(txid);
        if (tx == null) {
            throw new JMSException("Transaction '" + txid
                    + "' has not been started.");
        }
        return tx;
View Full Code Here

    /**
     * @see org.codehaus.activemq.service.TransactionManager#getXATransaction(org.codehaus.activemq.message.ActiveMQXid)
     */
    public Transaction getXATransaction(ActiveMQXid xid) throws XAException {
        Transaction tx = (Transaction) xaTxs.get(xid);
        if (tx == null) {
            XAException e = new XAException("Transaction '" + xid + "' has not been started.");
            e.errorCode = XAException.XAER_NOTA;
            throw e;
        }
View Full Code Here

TOP

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