Search in sources :

Example 11 with AbstractQueue

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

the class QueueWireTapInput method close.

@Override
public void close() {
    try {
        if (usage != null)
            ctx.usage.getEntity("inputs").removeEntity(usage);
    } catch (EntityRemoveException e) {
    }
    if (started) {
        AbstractQueue queue = ctx.ctx.queueManager.getQueueForInternalUse(destinationName);
        if (queue != null)
            queue.removeWireTapSubscriber(name, this);
        started = false;
    }
    ctx.stream.removeInput(this);
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 12 with AbstractQueue

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

the class XALiveContextImpl method commit.

public synchronized long commit(boolean onePhase) throws XAContextException {
    long fcDelay = 0;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/commit onePhase=" + onePhase + " ...");
    if (wasTimeout)
        throw new XAContextException(XAException.XA_RBTIMEOUT, "transaction timeout occured");
    if (closed)
        throw new XAContextException(XAException.XAER_PROTO, "XA transaction is in closed state");
    if (rollbackOnly)
        throw new XAContextException(XAException.XA_RBROLLBACK, "XA transaction is marked as rollback-only");
    for (int i = 0; i < recoveryTransactions.size(); i++) {
        Object[] wrapper = (Object[]) recoveryTransactions.get(i);
        try {
            ((AbstractQueue) wrapper[0]).commit(wrapper[1], xid);
            ctx.logSwiftlet.logInformation(ctx.xaSwiftlet.getName(), toString() + "commit xid=" + signature);
        } catch (Exception e) {
            if (!ctx.queueManager.isTemporaryQueue(((AbstractQueue) wrapper[0]).getQueueName()))
                ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "commit (two phase) xid=" + signature + ", failed for queue: " + ((AbstractQueue) wrapper[0]).getQueueName());
        }
    }
    if (onePhase) {
        if (prepared)
            throw new XAContextException(XAException.XAER_PROTO, "can't use one phase commit, XA transaction is in prepared state");
        for (int i = 0; i < transactions.size(); i++) {
            QueueTransaction t = (QueueTransaction) transactions.get(i);
            try {
                t.commit();
                if (t instanceof QueuePushTransaction)
                    fcDelay = Math.max(fcDelay, ((QueuePushTransaction) t).getFlowControlDelay());
            } catch (Exception e) {
                if (!ctx.queueManager.isTemporaryQueue(t.getQueueName()))
                    ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "commit (one phase) xid=" + signature + ", failed for queue: " + t.getQueueName());
            }
        }
    } else {
        if (!prepared)
            throw new XAContextException(XAException.XAER_PROTO, "can't use two phase commit, XA transaction is not in prepared state");
        for (int i = 0; i < transactions.size(); i++) {
            QueueTransaction t = (QueueTransaction) transactions.get(i);
            try {
                t.commit(xid);
                if (t instanceof QueuePushTransaction)
                    fcDelay = Math.max(fcDelay, ((QueuePushTransaction) t).getFlowControlDelay());
            } catch (Exception e) {
                if (!ctx.queueManager.isTemporaryQueue(t.getQueueName()))
                    ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "commit (two phase) xid=" + signature + ", failed for queue: " + t.getQueueName() + ", exception: " + e);
            }
        }
        if (registeredUsageList)
            removeUsageEntity();
    }
    closed = true;
    transactions.clear();
    recoveryTransactions.clear();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/commit onePhase=" + onePhase + " done");
    return fcDelay;
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) QueuePushTransaction(com.swiftmq.swiftlet.queue.QueuePushTransaction) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) XAException(javax.transaction.xa.XAException) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) QueueTransaction(com.swiftmq.swiftlet.queue.QueueTransaction)

Example 13 with AbstractQueue

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

the class XALiveContextImpl method _rollback.

private void _rollback(boolean reportException) {
    for (int i = 0; i < recoveryTransactions.size(); i++) {
        Object[] wrapper = (Object[]) recoveryTransactions.get(i);
        try {
            ((AbstractQueue) wrapper[0]).rollback(wrapper[1], xid, true);
            ctx.logSwiftlet.logInformation(ctx.xaSwiftlet.getName(), toString() + "rollback xid=" + signature);
        } catch (Exception e) {
            if (!ctx.queueManager.isTemporaryQueue(((AbstractQueue) wrapper[0]).getQueueName()))
                ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "rollback (two phase) xid=" + signature + ", failed for queue: " + ((AbstractQueue) wrapper[0]).getQueueName());
        }
    }
    for (int i = 0; i < transactions.size(); i++) {
        QueueTransaction t = (QueueTransaction) transactions.get(i);
        try {
            if (prepared)
                t.rollback(xid, true);
            else
                t.rollback();
        } catch (Exception e) {
            if (reportException && !ctx.queueManager.isTemporaryQueue(t.getQueueName()))
                ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "rollback xid=" + signature + ", failed for queue: " + t.getQueueName() + ", exception: " + e);
        }
    }
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) XAException(javax.transaction.xa.XAException) QueueTransaction(com.swiftmq.swiftlet.queue.QueueTransaction)

Example 14 with AbstractQueue

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

the class XARecoveryContextImpl method commit.

public synchronized long commit(boolean onePhase) throws XAContextException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/commit onePhase=" + onePhase + " ...");
    if (closed)
        throw new XAContextException(XAException.XAER_PROTO, "XA transaction is in closed state");
    if (onePhase)
        throw new XAContextException(XAException.XAER_PROTO, "Operation is not supported on a XARecoveryContextImpl");
    for (int i = 0; i < transactions.size(); i++) {
        Object[] wrapper = (Object[]) transactions.get(i);
        try {
            ((AbstractQueue) wrapper[0]).commit(wrapper[1], xid);
            ctx.logSwiftlet.logInformation(ctx.xaSwiftlet.getName(), toString() + "commit xid=" + signature);
        } catch (Exception e) {
            if (!ctx.queueManager.isTemporaryQueue(((AbstractQueue) wrapper[0]).getQueueName()))
                ctx.logSwiftlet.logError(ctx.xaSwiftlet.getName(), toString() + "commit (two phase) xid=" + signature + ", failed for queue: " + ((AbstractQueue) wrapper[0]).getQueueName());
        }
    }
    if (liveContext != null)
        liveContext.commit(onePhase);
    removeUsageEntity();
    close();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/commit onePhase=" + onePhase + " done");
    return 0;
}
Also used : AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) XAException(javax.transaction.xa.XAException) EntityAddException(com.swiftmq.mgmt.EntityAddException) XAContextException(com.swiftmq.swiftlet.xa.XAContextException)

Example 15 with AbstractQueue

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

the class XAResourceManagerSwiftletImpl method buildPreparedTransactions.

private void buildPreparedTransactions() throws Exception {
    List prepareRecordList = ctx.storeSwiftlet.getPrepareLogRecords();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "buildPreparedTransactions, recordList: " + prepareRecordList);
    if (prepareRecordList != null && prepareRecordList.size() > 0) {
        for (int i = 0; i < prepareRecordList.size(); i++) {
            PrepareLogRecord record = (PrepareLogRecord) prepareRecordList.get(i);
            AbstractQueue queue = getPreparedQueue(record.getQueueName());
            if (queue != null) {
                XidImpl xid = record.getGlobalTxId();
                Object localTxId = queue.buildPreparedTransaction(record);
                XALiveContextImpl xac = (XALiveContextImpl) contexts.get(xid);
                if (xac == null) {
                    xac = new XALiveContextImpl(ctx, xid, true);
                    xac.setRecovered(true);
                    xac.registerUsageList();
                    contexts.put(xid, xac);
                }
                xac._addTransaction(queue, localTxId);
            }
        }
    }
}
Also used : PrepareLogRecord(com.swiftmq.swiftlet.store.PrepareLogRecord) AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) XidImpl(com.swiftmq.jms.XidImpl)

Aggregations

AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)19 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)4 XAException (javax.transaction.xa.XAException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)3 QueueImpl (com.swiftmq.jms.QueueImpl)2 EntityAddException (com.swiftmq.mgmt.EntityAddException)2 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)2 MessageSelector (com.swiftmq.ms.MessageSelector)2 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)2 QueueTransaction (com.swiftmq.swiftlet.queue.QueueTransaction)2 JobException (com.swiftmq.swiftlet.scheduler.JobException)2 Iterator (java.util.Iterator)2 QueueMetricImpl (com.swiftmq.impl.queue.standard.cluster.v700.QueueMetricImpl)1 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 XidImpl (com.swiftmq.jms.XidImpl)1 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)1 SwiftletException (com.swiftmq.swiftlet.SwiftletException)1 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)1 MessageIndex (com.swiftmq.swiftlet.queue.MessageIndex)1