hippo4j
hippo4j copied to clipboard
使用代码配置动态线程池的话,如果不配置 spring.dynamic.thread-pool.executors 参数,则无法进行正常的告警通知
BUG 报告
在开始报告错误之前,请确保认真查看了以下步骤:
请在提交问题之前回答这些问题,谢谢。
你使用了哪个项目?hippo4j config 还是 hippo4j server?
hippo4j config
你使用了哪个版本?
1.3.1
预期行为
使用代码创建了动态线程池,期望接入动态线程池的告警和监控机制
实际行为
无法进行正常的告警通知
原因分析(如果可以)
cn.hippo4j.core.springboot.starter.support.DynamicThreadPoolPostProcessor#fillPoolAndRegister 里面会从 bootstrapCoreProperties 获取 spring.dynamic.thread-pool.executors 配置,获取不到的话,就不进行 GlobalNotifyAlarmManage.put(threadPoolId, threadPoolNotifyAlarm); 导致后续的告警通知无法推送
问题重现步骤
1、使用代码配置动态线程池 @Bean(name = "batchNotifyExecutor", destroyMethod = "shutdown") @DynamicThreadPool public ExecutorService batchNotifyExecutor() { return ThreadPoolBuilder.builder() .threadFactory(CONTRACT_THREAD_POOL_BATCH_NOTIFY) .threadPoolId(CONTRACT_THREAD_POOL_BATCH_NOTIFY) .corePoolSize(2) .maxPoolNum(20) .keepAliveTime(20, TimeUnit.SECONDS) .workQueue(new ArrayBlockingQueue<>(100)) .rejected(new CallerRunsPolicy()) .dynamicPool() .build(); }
2、配置文件中新增配置 spring.dynamic.thread-pool.enable = true spring.dynamic.thread-pool.banner = true spring.dynamic.thread-pool.collect = true spring.dynamic.thread-pool.notify-platforms[0].platform = WECHAT ######这里为了隐私把token隐藏了 spring.dynamic.thread-pool.notify-platforms[0].token = xxxxxxx spring.dynamic.thread-pool.alarm = true spring.dynamic.thread-pool.check-state-interval = 10000 spring.dynamic.thread-pool.active-alarm = 80 spring.dynamic.thread-pool.capacity-alarm = 80 spring.dynamic.thread-pool.alarm-interval = 10 spring.dynamic.thread-pool.receive = 111 spring.dynamic.thread-pool.apollo.namespace = application spring.dynamic.thread-pool.config-file-type = properties
用于重现此问题的示例代码(例如 GitHub 链接)
spring.dynamic.thread-pool.executors 是 hippo4j 的核心,目前暂时不支持仅报警模式