setSave();
//setCtx(cKey);
// Denying the non acknowledged messages:
AgentId id;
boolean prepared = false;
for (Iterator ids = activeCtx.getDeliveringQueues(); ids.hasNext();) {
id = (AgentId) ids.next();
for (Iterator xids = activeCtx.getTxIds(); xids.hasNext();) {
Xid xid = (Xid) xids.next();
if (activeCtx.isPrepared(xid)) {
prepared = true;
break;
}
}
if (!prepared)
sendNot(id, new DenyRequest(key));
prepared = false;
}
// Removing or deactivating the subscriptions:
String subName = null;
ClientSubscription sub;
List topics = new Vector();
for (Iterator subs = activeCtx.getActiveSubs(); subs.hasNext();) {
subName = (String) subs.next();
sub = (ClientSubscription) subsTable.get(subName);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Deactivate subscription " + subName + ", topic id = " + sub.getTopicId());
if (sub.getDurable()) {
sub.deactivate();
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Durable subscription" + subName + " de-activated.");
} else {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, " -> topicsTable = " + topicsTable);
sub.delete();
subsTable.remove(subName);
try {
MXWrapper.unregisterMBean(getSubMBeanName(subName));
} catch (Exception e) {
if (logger.isLoggable(BasicLevel.WARN))
logger.log(BasicLevel.WARN, " - Problem when unregistering ClientSubscriptionMbean", e);
}
TopicSubscription tSub = (TopicSubscription) topicsTable.get(sub
.getTopicId());
tSub.removeSubscription(subName);
if (!topics.contains(sub.getTopicId()))
topics.add(sub.getTopicId());
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Temporary subscription" + subName + " deleted.");
}
}
// Browsing the topics which at least have one subscription removed.
for (Iterator topicIds = topics.iterator(); topicIds.hasNext();)
updateSubscriptionToTopic((AgentId) topicIds.next(), -1, -1);
// Deleting the temporary destinations:
AgentId destId;
for (Iterator dests = activeCtx.getTempDestinations(); dests.hasNext();) {
destId = (AgentId) dests.next();
activeCtx.removeTemporaryDestination(destId);
deleteTemporaryDestination(destId);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Deletes temporary" + " destination " + destId.toString());
}
// Saving the prepared transactions.
Iterator xids = activeCtx.getTxIds();
Xid xid;