feat(REQ-4418) - Starter 增加 MQ 必须实现的监听

This commit is contained in:
wangli 2025-08-26 10:33:41 +08:00
parent b63f824fae
commit c95cdc16ac

View File

@ -38,9 +38,7 @@ public class ImplementationReadyChecker implements ApplicationListener<Applicati
// 获取所有实现了目标接口的Bean
Map<String, ProcessInstanceEventHandler> handlers = context.getBeansOfType(TARGET_INTERFACE);
if (handlers.isEmpty()) {
// 如果没有找到任何实现类可以选择抛出异常或记录警告
log.info("未找到实现 " + TARGET_INTERFACE.getName() + " 接口的Bean, 请确保至少有一个实现类被正确扫描和注册。");
// throw new IllegalStateException("未找到实现 " + TARGET_INTERFACE.getName() + " 接口的Bean, 请确保至少有一个实现类被正确扫描和注册。");
log.warn("未找到实现 {} 接口的Bean, 请确保至少有一个实现类被正确扫描和注册。", TARGET_INTERFACE.getName());
}
// 记录每个方法是否被实现
@ -87,13 +85,10 @@ public class ImplementationReadyChecker implements ApplicationListener<Applicati
log.info("实现 {} 接口的Bean数量: {}", TARGET_INTERFACE.getName(), handlers.size());
log.info("方法实现情况:(二进制:{})(十进制:{})", String.format("%4s", Integer.toBinaryString(binaryResult)).replace(' ', '0'), binaryResult);
if (!unimplementedMethods.isEmpty()) {
log.info("以下方法未被任何实现类覆盖: " + String.join(", ", unimplementedMethods) +
"。请确保至少有一个实现类覆盖这些方法以处理相应的事件。");
// throw new IllegalStateException("以下方法未被任何实现类覆盖: " + String.join(", ", unimplementedMethods) +
// "。请确保至少有一个实现类覆盖这些方法以处理相应的事件。");
log.error("以下方法未被任何实现类覆盖: {}。请确保至少有一个实现类覆盖这些方法以处理相应的事件。", String.join(", ", unimplementedMethods));
} else {
log.info("Congratulations, passed the verification");
log.info("祝贺,已通过校验!");
log.info("祝贺,已通过必接事件的校验!但仍然请确保您的实现类逻辑正确无误,不允许出现空实现,否则生产问题自行负责!");
}
}
}