logger.log(BasicLevel.DEBUG, " -> topicsTable.remove(" + agId + ')');
TopicSubscription tSub = (TopicSubscription) topicsTable.remove(agId);
if (tSub != null) {
String name;
ClientSubscription sub;
DestinationException exc;
exc = new DestinationException("Destination " + agId + " does not exist.");
for (Iterator e = tSub.getNames(); e.hasNext();) {
name = (String) e.next();
sub = (ClientSubscription) subsTable.remove(name);
try {
MXWrapper.unregisterMBean(getSubMBeanName(name));
} catch (Exception e1) {
if (logger.isLoggable(BasicLevel.WARN))
logger.log(BasicLevel.WARN, " - Problem when unregistering ClientSubscriptionMbean", e1);
}
sub.delete();
try {
setCtx(sub.getContextId());
activeCtx.removeSubName(name);
doReply(new MomExceptionReply(sub.getSubRequestId(), exc));
} catch (StateException pExc) {}
}
return;
}
if (not instanceof AbstractRequestNot) {
AbstractRequestNot req = (AbstractRequestNot) not;
// If the wrapped request is messages sending,forwarding them to the DMQ:
if (req instanceof ClientMessages) {
// If the queue actually was a dead message queue, updating its
// identifier:
if (dmqId != null && agId.equals(dmqId)) {
// state change, so save.
setSave();
dmqId = null;
for (Iterator subs = subsTable.values().iterator(); subs.hasNext();)
((ClientSubscription) subs.next()).setDMQId(null);
}
// Sending the messages again if not coming from the default DMQ:
if (Queue.getDefaultDMQId() != null && !agId.equals(Queue.getDefaultDMQId())) {
DMQManager dmqManager = new DMQManager(dmqId, null);
Iterator msgs = ((ClientMessages) req).getMessages().iterator();
while (msgs.hasNext()) {
org.objectweb.joram.shared.messages.Message msg = (org.objectweb.joram.shared.messages.Message) msgs.next();
nbMsgsSentToDMQSinceCreation++;
dmqManager.addDeadMessage(msg, MessageErrorConstants.DELETED_DEST);
}
dmqManager.sendToDMQ();
}
DestinationException exc;
exc = new DestinationException("Destination " + agId + " does not exist.");
MomExceptionReply mer = new MomExceptionReply(req.getRequestId(), exc);
try {
setCtx(req.getClientContext());
// Contrary to a receive, send the error even if the
// connection is not started.
doReply(mer);
} catch (StateException se) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "", se);
// Do nothing (the context doesn't exist any more).
}
} else if (req instanceof ReceiveRequest) {
DestinationException exc = new DestinationException("Destination " + agId + " does not exist.");
MomExceptionReply mer = new MomExceptionReply(req.getRequestId(), exc);
try {
setCtx(req.getClientContext());
if (activeCtx.getActivated()) {
doReply(mer);