Search in sources :

Example 1 with QueueException

use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.

the class TopicBroker method rollback.

/**
 * Rolls back the transaction with the given transaction id. If
 * the flag <code>setRedelivered</code> is set then the JMS properties for
 * redelivery and delivery count of messages pulled within this transaction
 * are updated
 *
 * @param transactionId  transaction id
 * @param setRedelivered specifies JMS redelivery setting
 * @throws QueueException on error
 */
public void rollback(Object transactionId, boolean setRedelivered) throws QueueException {
    lockAndWaitAsyncFinished();
    try {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "rollback");
        TopicTransaction transaction = (TopicTransaction) transactionId;
        transaction.rollback();
        transactions.set(transaction.getTransactionId(), null);
    } catch (Exception e) {
        throw new QueueException(e.getMessage());
    } finally {
        lock.unlock();
    }
}
Also used : QueueException(com.swiftmq.swiftlet.queue.QueueException) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Example 2 with QueueException

use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.

the class TopicBroker method commit.

/**
 * Commit the transaction with the given transaction id
 *
 * @param transactionId transaction id
 * @throws QueueException on error
 */
public void commit(Object transactionId) throws QueueException {
    lockAndWaitAsyncFinished();
    try {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "commit");
        TopicTransaction transaction = (TopicTransaction) transactionId;
        long delay = transaction.commit();
        TopicFlowController fc = (TopicFlowController) getFlowController();
        if (fc != null)
            fc.setLastDelay(delay);
        transactions.set(transaction.getTransactionId(), null);
    } catch (Exception e) {
        throw new QueueException(e.getMessage());
    } finally {
        lock.unlock();
    }
}
Also used : QueueException(com.swiftmq.swiftlet.queue.QueueException) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Example 3 with QueueException

use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.

the class TopicBroker method commit.

public void commit(Object localTransactionId, XidImpl globalTransactionId) throws QueueException {
    lockAndWaitAsyncFinished();
    try {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "commit, globalTxId=" + globalTransactionId);
        TopicTransaction transaction = (TopicTransaction) localTransactionId;
        long delay = transaction.commit(globalTransactionId);
        TopicFlowController fc = (TopicFlowController) getFlowController();
        if (fc != null)
            fc.setLastDelay(delay);
        transactions.set(transaction.getTransactionId(), null);
    } catch (Exception e) {
        throw new QueueException(e.getMessage());
    } finally {
        lock.unlock();
    }
}
Also used : QueueException(com.swiftmq.swiftlet.queue.QueueException) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Example 4 with QueueException

use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-client by iitsoftware.

the class ReplyNE method createException.

private void createException(String className, String msg) throws Exception {
    if (className.equals("com.swiftmq.swiftlet.queue.QueueException"))
        exception = new QueueException(msg);
    else if (className.equals("com.swiftmq.swiftlet.queue.QueueLimitException"))
        exception = new QueueLimitException(msg);
    else if (className.equals("com.swiftmq.swiftlet.queue.UnknownQueueException"))
        exception = new InvalidDestinationException(msg);
    else if (className.equals("com.swiftmq.swiftlet.auth.ResourceLimitException"))
        exception = new ResourceLimitException(msg);
    else if (className.equals("com.swiftmq.swiftlet.auth.AuthenticationException"))
        exception = new AuthenticationException(msg);
    else if (className.equals("javax.jms.InvalidDestinationException"))
        exception = new InvalidDestinationException(msg);
    else
        exception = new Exception(className + ": " + msg);
}
Also used : QueueLimitException(com.swiftmq.swiftlet.queue.QueueLimitException) AuthenticationException(com.swiftmq.swiftlet.auth.AuthenticationException) QueueException(com.swiftmq.swiftlet.queue.QueueException) InvalidDestinationException(javax.jms.InvalidDestinationException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) AuthenticationException(com.swiftmq.swiftlet.auth.AuthenticationException) ResourceLimitException(com.swiftmq.swiftlet.auth.ResourceLimitException) QueueException(com.swiftmq.swiftlet.queue.QueueException) QueueLimitException(com.swiftmq.swiftlet.queue.QueueLimitException) InvalidDestinationException(javax.jms.InvalidDestinationException) IOException(java.io.IOException)

Example 5 with QueueException

use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.

the class TransactionRegistry method discharge.

public void discharge(TxnIdIF btxnId, boolean rollback) throws EndWithErrorException {
    String txnId = new String(((TransactionId) btxnId).getValue());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge, txnId=" + txnId + ", rollback=" + rollback);
    lock.lock();
    try {
        ActiveTxEntry activeTxEntry = (ActiveTxEntry) activeTx.remove(txnId);
        if (activeTxEntry == null) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge, txnId=" + txnId + ", not found!");
            throw new SessionEndException(TransactionError.UNKNOWN_ID, new AMQPString("Transaction id not found: " + txnId));
        }
        if (activeTxEntry.inboundTxEntryMap != null) {
            for (Iterator iter = activeTxEntry.inboundTxEntryMap.entrySet().iterator(); iter.hasNext(); ) {
                Map.Entry entry = (Map.Entry) iter.next();
                InboundTxEntry inboundTxEntry = (InboundTxEntry) entry.getValue();
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge txnid=" + txnId + ", linkName=" + entry.getKey());
                if (rollback)
                    inboundTxEntry.tx.rollback();
                else
                    inboundTxEntry.tx.commit();
                inboundTxEntry.targetLink.setFlowcontrolDelay(inboundTxEntry.tx.getFlowControlDelay());
                inboundTxEntry.targetLink.decreaseActiveTransactions();
                inboundTxEntry.targetLink.closeResource();
            }
            activeTxEntry.inboundTxEntryMap.clear();
        }
        if (activeTxEntry.outboundTxEntryMap != null) {
            for (Iterator iter = activeTxEntry.outboundTxEntryMap.entrySet().iterator(); iter.hasNext(); ) {
                Map.Entry entry = (Map.Entry) iter.next();
                long deliveryId = ((Long) entry.getKey()).longValue();
                OutboundTxEntry outboundTxEntry = (OutboundTxEntry) entry.getValue();
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge txnid=" + txnId + ", deliveryId=" + deliveryId);
                if (rollback) {
                    if (outboundTxEntry.sourceLink != null)
                        sessionHandler.settleOutbound(deliveryId, RELEASED);
                } else
                    sessionHandler.settleOutbound(deliveryId, outboundTxEntry.deliveryStateIF);
                if (outboundTxEntry.sourceLink != null) {
                    outboundTxEntry.sourceLink.decreaseActiveTransactions();
                    outboundTxEntry.sourceLink.closeResource();
                }
            }
            activeTxEntry.outboundTxEntryMap.clear();
            sessionHandler.sendOutboundDeliveries();
        }
    } catch (QueueException e) {
        throw new ConnectionEndException(AmqpError.INTERNAL_ERROR, new AMQPString(e.toString()));
    } finally {
        lock.unlock();
    }
}
Also used : AMQPString(com.swiftmq.amqp.v100.types.AMQPString) Iterator(java.util.Iterator) QueueException(com.swiftmq.swiftlet.queue.QueueException) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

QueueException (com.swiftmq.swiftlet.queue.QueueException)20 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)8 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)7 JMSException (javax.jms.JMSException)7 Property (com.swiftmq.mgmt.Property)3 AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)3 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)3 NonPersistentStore (com.swiftmq.swiftlet.store.NonPersistentStore)3 AMQPString (com.swiftmq.amqp.v100.types.AMQPString)2 MessageImpl (com.swiftmq.jms.MessageImpl)2 QueueImpl (com.swiftmq.jms.QueueImpl)2 TopicImpl (com.swiftmq.jms.TopicImpl)2 EntityList (com.swiftmq.mgmt.EntityList)2 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)2 PersistentStore (com.swiftmq.swiftlet.store.PersistentStore)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TransactionalState (com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionalState)1 TxnIdIF (com.swiftmq.amqp.v100.generated.transactions.coordination.TxnIdIF)1