public Response processRemoveSession(SessionId id) throws Exception {
ConnectionId connectionId = id.getParentId();
ConnectionState cs = lookupConnectionState(connectionId);
SessionState session = cs.getSessionState(id);
if( session == null )
throw new IllegalStateException("Cannot remove session that had not been registered: "+id);
// Don't let new consumers or producers get added while we are closing this down.
session.shutdown();
// Cascade the connection stop to the consumers and producers.
for (Iterator iter = session.getConsumerIds().iterator(); iter.hasNext();) {
ConsumerId consumerId = (ConsumerId) iter.next();
try {
processRemoveConsumer(consumerId);
}
catch (Throwable e) {
log.warn("Failed to remove consumer: " + consumerId + ". Reason: " + e, e);
}
}
for (Iterator iter = session.getProducerIds().iterator(); iter.hasNext();) {
ProducerId producerId = (ProducerId) iter.next();
try {
processRemoveProducer(producerId);
}
catch (Throwable e) {
log.warn("Failed to remove producer: " + producerId + ". Reason: " + e, e);
}
}
cs.removeSession(id);
broker.removeSession(cs.getContext(), session.getInfo());
return null;
}