use of com.swiftmq.swiftlet.queue.QueueTransaction in project swiftmq-ce by iitsoftware.
the class TransactionManager method rollback.
synchronized void rollback(boolean start) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/rollback");
for (Iterator iter = transactions.iterator(); iter.hasNext(); ) {
QueueTransaction t = (QueueTransaction) iter.next();
t.rollback();
}
if (start)
startTransactions();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/rollback done");
}
use of com.swiftmq.swiftlet.queue.QueueTransaction 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;
}
use of com.swiftmq.swiftlet.queue.QueueTransaction 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);
}
}
}
use of com.swiftmq.swiftlet.queue.QueueTransaction in project swiftmq-ce by iitsoftware.
the class TransactionManager method commit.
synchronized void commit() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commit");
for (Iterator iter = transactions.iterator(); iter.hasNext(); ) {
QueueTransaction t = (QueueTransaction) iter.next();
t.commit();
}
startTransactions();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commit done");
}
use of com.swiftmq.swiftlet.queue.QueueTransaction in project swiftmq-ce by iitsoftware.
the class TransactionManager method rollback.
synchronized void rollback(boolean start) throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/rollback");
for (Iterator iter = transactions.iterator(); iter.hasNext(); ) {
QueueTransaction t = (QueueTransaction) iter.next();
t.rollback();
}
if (start)
startTransactions();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/rollback done");
}
Aggregations