use of com.swiftmq.swiftlet.store.StoreException in project swiftmq-ce by iitsoftware.
the class StoreTransactionImpl method checkClosedAsync.
protected boolean checkClosedAsync(AsyncCompletionCallback callback) {
if (closed) {
callback.setException(new StoreException("Transaction is closed"));
callback.notifyCallbackStack(false);
}
return closed;
}
use of com.swiftmq.swiftlet.store.StoreException in project swiftmq-ce by iitsoftware.
the class StoreTransactionImpl method commit.
public void commit() throws StoreException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/commit...");
if (closed)
throw new StoreException("Transaction is closed");
try {
if (journal != null && journal.size() > 0) {
ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null, messagePageRefs));
sem.waitHere();
}
ctx.transactionManager.removeTxId(txId);
close();
} catch (Exception e) {
throw new StoreException(e.toString());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/commit...done.");
}
use of com.swiftmq.swiftlet.store.StoreException in project swiftmq-ce by iitsoftware.
the class CompositeStoreTransactionImpl method abortTransaction.
public void abortTransaction(AsyncCompletionCallback callback) {
AsyncCompletionCallback localCallback = createLocalCallback(callback);
checkClosedAsync(localCallback);
if (localCallback.isNotified())
return;
boolean doNotify = true;
if (journal != null && journal.size() > 0) {
try {
doNotify = false;
if (keysRemoved != null && markRedelivered)
ctx.recoveryManager.abort(new AbortLogRecord(txId, null, journal, this, null));
else
ctx.recoveryManager.abort(new AbortLogRecord(txId, null, journal, this, localCallback));
} catch (Exception e) {
localCallback.setException(new StoreException(e.toString()));
localCallback.notifyCallbackStack(false);
removeTxId();
return;
}
}
if (keysRemoved != null && markRedelivered) {
List newJournal = new ArrayList();
try {
for (int i = 0; i < keysRemoved.size(); i++) {
RemovedKeyEntry entry = keysRemoved.get(i);
entry.queueIndex.setJournal(newJournal);
entry.queueIndex.incDeliveryCount(entry.key);
}
doNotify = false;
// don't wonder, we are committing the redelivered settings
ctx.recoveryManager.commit(new CommitLogRecord(txId, null, newJournal, this, localCallback, null));
} catch (Exception e) {
localCallback.setException(new StoreException(e.toString()));
localCallback.notifyCallbackStack(false);
removeTxId();
return;
}
}
if (doNotify)
callback.notifyCallbackStack(true);
}
use of com.swiftmq.swiftlet.store.StoreException in project swiftmq-ce by iitsoftware.
the class CompositeStoreTransactionImpl method abortTransaction.
public void abortTransaction() throws StoreException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/abortTransaction...");
if (closed)
throw new StoreException("Transaction is closed");
try {
if (journal != null && journal.size() > 0) {
if (keysRemoved != null && markRedelivered)
ctx.recoveryManager.abort(new AbortLogRecord(txId, null, journal, null));
else {
ctx.recoveryManager.abort(new AbortLogRecord(txId, sem, journal, this));
sem.waitHere();
}
}
if (keysRemoved != null && markRedelivered) {
List newJournal = new ArrayList();
for (int i = 0; i < keysRemoved.size(); i++) {
RemovedKeyEntry entry = keysRemoved.get(i);
entry.queueIndex.setJournal(newJournal);
entry.queueIndex.incDeliveryCount(entry.key);
}
// don't wonder, we are committing the redelivered settings
ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, newJournal, this, null));
sem.waitHere();
}
removeTxId();
close();
} catch (Exception e) {
throw new StoreException(e.getMessage());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/abortTransaction...done.");
}
use of com.swiftmq.swiftlet.store.StoreException in project swiftmq-ce by iitsoftware.
the class CompositeStoreTransactionImpl method checkClosedAsync.
protected void checkClosedAsync(AsyncCompletionCallback callback) {
if (closed) {
callback.setException(new StoreException("Transaction is closed"));
callback.notifyCallbackStack(false);
}
}
Aggregations