use of com.swiftmq.swiftlet.store.CompositeStoreTransaction in project swiftmq-ce by iitsoftware.
the class TopicTransaction method rollback.
protected void rollback() throws Exception {
if (subscriberTransactions == null)
return;
List durPersSubs = new ArrayList(subscriberTransactions.length);
for (int i = 0; i < subscriberTransactions.length; i++) {
TopicSubscriberTransaction sub = subscriberTransactions[i];
if (sub != null) {
TopicSubscription subscription = sub.getTopicSubscription();
if (subscription.isRemote() || !subscription.isDurable() || !sub.isPersistentMessageIncluded()) {
try {
sub.rollback();
} catch (QueueTransactionClosedException ignored) {
}
} else
durPersSubs.add(sub);
}
}
int size = durPersSubs.size();
if (size > 0) {
if (size == 1) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(0);
try {
sub.rollback();
} catch (QueueTransactionClosedException ignored) {
}
} else {
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
sub.getTransaction().lockQueue();
}
CompositeStoreTransaction compositeTx = ctx.storeSwiftlet.createCompositeStoreTransaction();
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
try {
sub.getTransaction().setCompositeStoreTransaction(compositeTx);
sub.rollback();
sub.getTransaction().setCompositeStoreTransaction(null);
} catch (QueueTransactionClosedException ignored) {
}
}
compositeTx.commitTransaction();
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
sub.getTransaction().unlockQueue(false);
}
}
}
subscriberTransactions = null;
}
use of com.swiftmq.swiftlet.store.CompositeStoreTransaction in project swiftmq-ce by iitsoftware.
the class TopicTransaction method rollback.
protected void rollback(AsyncCompletionCallback callback) {
final RollbackJoin join = new RollbackJoin(callback);
if (subscriberTransactions != null) {
final List durPersSubs = new ArrayList(subscriberTransactions.length);
for (int i = 0; i < subscriberTransactions.length; i++) {
TopicSubscriberTransaction sub = subscriberTransactions[i];
if (sub != null) {
TopicSubscription subscription = sub.getTopicSubscription();
if (subscription.isRemote() || !subscription.isDurable() || !sub.isPersistentMessageIncluded()) {
join.incNumberCallbacks();
sub.rollback(new RollbackCallback(join));
} else
durPersSubs.add(sub);
}
}
final int size = durPersSubs.size();
if (size > 0) {
if (size == 1) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(0);
join.incNumberCallbacks();
sub.rollback(new RollbackCallback(join));
} else {
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
sub.getTransaction().lockQueue();
}
CompositeStoreTransaction compositeTx = ctx.storeSwiftlet.createCompositeStoreTransaction();
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
try {
sub.getTransaction().setCompositeStoreTransaction(compositeTx);
sub.rollback();
sub.getTransaction().setCompositeStoreTransaction(null);
sub.getTransaction().unlockQueue(true);
} catch (Exception ignored) {
}
}
join.incNumberCallbacks();
compositeTx.commitTransaction(new AsyncCompletionCallback() {
public void done(boolean success) {
for (int i = 0; i < size; i++) {
TopicSubscriberTransaction sub = (TopicSubscriberTransaction) durPersSubs.get(i);
sub.getTransaction().unmarkAsyncActive();
}
join.done(this, success);
}
});
}
}
subscriberTransactions = null;
}
join.setBlocked(false);
}
use of com.swiftmq.swiftlet.store.CompositeStoreTransaction in project swiftmq-ce by iitsoftware.
the class TransactionManager method commitWithGlobalLock.
private void commitWithGlobalLock() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commitWithGlobalLock, transactions.size=" + transactions.size());
CompositeStoreTransaction compTx = ctx.storeSwiftlet.createCompositeStoreTransaction();
compTx.setReferencable(false);
ctx.queueManager.lockMultiQueue();
lock();
try {
for (Iterator iter = transactions.iterator(); iter.hasNext(); ) {
Pair p = (Pair) iter.next();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commitWithGlobalLock, t=" + p.tx + ", closed=" + p.tx.isClosed());
try {
p.tx.setCompositeStoreTransaction(compTx);
p.tx.commit();
p.tx.setCompositeStoreTransaction(null);
} catch (QueueTransactionClosedException e) {
// Happens when temp queues have been deleted meanwhile
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commitWithGlobalLock, t=" + p.tx + ", QueueTransactionClosedException, remove");
iter.remove();
p.tx.unlockQueue(false);
}
}
compTx.commitTransaction();
} finally {
unlock();
ctx.queueManager.unlockMultiQueue();
startTransactions();
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/" + toString() + "/commitWithGlobalLock done");
}
use of com.swiftmq.swiftlet.store.CompositeStoreTransaction in project swiftmq-ce by iitsoftware.
the class StreamContext method commitTransactionsGlobalLock.
public void commitTransactionsGlobalLock() throws Exception {
notifyTransactionFlushListeners();
CompositeStoreTransaction compTx = ctx.storeSwiftlet.createCompositeStoreTransaction();
compTx.setReferencable(false);
try {
ctx.queueManager.lockMultiQueue();
lock();
for (int i = 0; i < queueTransactions.size(); i++) {
Entry entry = queueTransactions.get(i);
entry.transaction.setCompositeStoreTransaction(compTx);
entry.transaction.commit();
entry.transaction.setCompositeStoreTransaction(null);
}
compTx.commitTransaction();
} finally {
try {
unlock();
} catch (Exception e) {
}
ctx.queueManager.unlockMultiQueue();
}
for (int i = 0; i < queueTransactions.size(); i++) {
Entry entry = queueTransactions.get(i);
if (entry.listener != null)
entry.listener.transactionFinished();
}
queueTransactions.clear();
}
use of com.swiftmq.swiftlet.store.CompositeStoreTransaction in project swiftmq-ce by iitsoftware.
the class ClusteredTransactionId method getCompositeStoreTransaction.
public CompositeStoreTransaction getCompositeStoreTransaction() {
CompositeStoreTransaction ct = null;
if (messageBasedDispatch) {
for (Iterator iter = queueMap.entrySet().iterator(); iter.hasNext(); ) {
Entry entry = (Entry) ((Map.Entry) iter.next()).getValue();
ct = entry.abstractQueue.getCompositeStoreTransaction(entry.transaction);
break;
}
} else {
if (baseQueue == null)
return null;
ct = baseQueue.getCompositeStoreTransaction(baseTx);
}
return ct;
}
Aggregations