说在前面
管理请求 CLEAN_UNUSED_TOPIC 清除无用的topic
源码解析
进入这个方法org.apache.rocketmq.broker.processor.AdminBrokerProcessor#cleanUnusedTopic
public RemotingCommand cleanUnusedTopic() {
log.warn("invoke cleanUnusedTopic start.");
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
// =》
brokerController.getMessageStore().cleanUnusedTopic(brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
log.warn("invoke cleanUnusedTopic end.");
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
进入这个方法org.apache.rocketmq.store.DefaultMessageStore#cleanUnusedTopic清除无用的topic
@Override
public int cleanUnusedTopic(Set<String> topics) {
// 遍历缓存的消息队列
Iterator<Entry<String, ConcurrentMap<Integer, ConsumeQueue