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);
}
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;
}
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);
}
}
}
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;
}
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);
}
}
}
}
Aggregations