Merge pull request #377 from mabaiwan/develop

Configuration change notification & alarm notification reconfiguration
pull/382/merge
小马哥 2 years ago committed by GitHub
commit 86abcd77c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,24 +34,6 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<optional>true</optional>
<!-- User feedback that javax.jms cannot be downloaded, log4j is not found useful, so it is excluded for the time being. -->
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
</dependencies>
<build>

@ -20,6 +20,11 @@
<artifactId>hippo4j-common</artifactId>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-message</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>

@ -17,18 +17,18 @@
package cn.hippo4j.core.executor;
import cn.hippo4j.common.notify.HippoSendMessageService;
import cn.hippo4j.common.notify.NotifyTypeEnum;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.core.toolkit.TraceContextUtil;
import cn.hippo4j.common.toolkit.CalculateUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.common.toolkit.CalculateUtil;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.TraceContextUtil;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hutool.core.util.StrUtil;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@ -17,7 +17,7 @@
package cn.hippo4j.core.executor.manage;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@ -10,7 +10,6 @@
<artifactId>hippo4j-discovery</artifactId>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-all</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-message</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-common</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<optional>true</optional>
<!-- User feedback that javax.jms cannot be downloaded, log4j is not found useful, so it is excluded for the time being. -->
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Title>${project.artifactId}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Build-Time>${maven.build.timestamp}</Build-Time>
<Built-By>chen.ma</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.hippo4j.common.api;
package cn.hippo4j.message.api;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import java.util.List;
import java.util.Map;

@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.message.config;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.platform.DingSendMessageHandler;
import cn.hippo4j.message.platform.LarkSendMessageHandler;
import cn.hippo4j.message.platform.WeChatSendMessageHandler;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.message.service.SendMessageHandler;
import org.springframework.context.annotation.Bean;
/**
* Message configuration.
*/
public class MessageConfiguration {
@Bean
public HippoSendMessageService hippoSendMessageService(NotifyConfigBuilder serverNotifyConfigBuilder,
AlarmControlHandler alarmControlHandler) {
return new HippoBaseSendMessageService(serverNotifyConfigBuilder, alarmControlHandler);
}
@Bean
public AlarmControlHandler alarmControlHandler() {
return new AlarmControlHandler();
}
@Bean
public SendMessageHandler dingSendMessageHandler() {
return new DingSendMessageHandler();
}
@Bean
public SendMessageHandler larkSendMessageHandler() {
return new LarkSendMessageHandler();
}
@Bean
public SendMessageHandler weChatSendMessageHandler() {
return new WeChatSendMessageHandler();
}
}

@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.dto;
import cn.hutool.core.util.StrUtil;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import lombok.Builder;
import lombok.Data;
@ -49,6 +49,6 @@ public class AlarmControlDTO {
* @return
*/
public String buildPk() {
return StrUtil.builder(threadPool, "+", platform).toString();
return threadPool + "+" + platform;
}
}

@ -15,8 +15,9 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.dto;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.dto;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.enums;
/**
* Notify platform enum.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.enums;
/**
* Notify type enum.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
/**
* Ding alarm constants.

@ -15,15 +15,15 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.common.notify.NotifyPlatformEnum;
import cn.hippo4j.common.notify.NotifyTypeEnum;
import cn.hippo4j.common.notify.SendMessageHandler;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.enums.NotifyPlatformEnum;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.service.SendMessageHandler;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.dingtalk.api.DefaultDingTalkClient;
@ -42,7 +42,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
import static cn.hippo4j.common.notify.platform.DingAlarmConstants.*;
import static cn.hippo4j.message.platform.DingAlarmConstants.*;
/**
* Send ding notification message.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
/**
* Lark alarm constants.

@ -15,14 +15,14 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.common.notify.NotifyPlatformEnum;
import cn.hippo4j.common.notify.NotifyTypeEnum;
import cn.hippo4j.common.notify.SendMessageHandler;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.enums.NotifyPlatformEnum;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.service.SendMessageHandler;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
@ -35,7 +35,7 @@ import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors;
import static cn.hippo4j.common.notify.platform.LarkAlarmConstants.*;
import static cn.hippo4j.message.platform.LarkAlarmConstants.*;
/**
* Send lark notification message.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
/**
* We chat alarm constants.

@ -15,13 +15,16 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.platform;
package cn.hippo4j.message.platform;
import cn.hippo4j.common.notify.*;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.enums.NotifyPlatformEnum;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.service.SendMessageHandler;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
@ -32,7 +35,7 @@ import lombok.extern.slf4j.Slf4j;
import java.util.Objects;
import static cn.hippo4j.common.notify.platform.WeChatAlarmConstants.*;
import static cn.hippo4j.message.platform.WeChatAlarmConstants.*;
/**
* WeChat send message handler.

@ -15,10 +15,10 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request;
package cn.hippo4j.message.request;
import cn.hippo4j.common.notify.NotifyTypeEnum;
import cn.hippo4j.common.notify.request.base.BaseNotifyRequest;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.request.base.BaseNotifyRequest;
import lombok.Data;
import lombok.experimental.Accessors;

@ -15,9 +15,9 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request;
package cn.hippo4j.message.request;
import cn.hippo4j.common.notify.request.base.BaseNotifyRequest;
import cn.hippo4j.message.request.base.BaseNotifyRequest;
import lombok.Data;
/**

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request;
package cn.hippo4j.message.request;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request;
package cn.hippo4j.message.request;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request;
package cn.hippo4j.message.request;
import lombok.AllArgsConstructor;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request.base;
package cn.hippo4j.message.request.base;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify.request.base;
package cn.hippo4j.message.request.base;
/**
* Notify request.

@ -15,9 +15,10 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.service;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.message.dto.AlarmControlDTO;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.cache.Cache;

@ -15,12 +15,15 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.service;
import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.dto.AlarmControlDTO;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Maps;

@ -15,10 +15,11 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.service;
import cn.hippo4j.common.notify.request.AlarmNotifyRequest;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.enums.NotifyTypeEnum;
import cn.hippo4j.message.request.AlarmNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
/**
* Hippo4j send message service.

@ -15,9 +15,10 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.service;
import cn.hippo4j.common.notify.request.base.NotifyRequest;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.request.base.NotifyRequest;
/**
* Send message handler.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.notify;
package cn.hippo4j.message.service;
import lombok.Data;
import lombok.NoArgsConstructor;

@ -17,15 +17,7 @@
package cn.hippo4j.core.springboot.starter.config;
import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.notify.AlarmControlHandler;
import cn.hippo4j.common.notify.HippoBaseSendMessageService;
import cn.hippo4j.common.notify.HippoSendMessageService;
import cn.hippo4j.common.notify.SendMessageHandler;
import cn.hippo4j.common.notify.platform.DingSendMessageHandler;
import cn.hippo4j.common.notify.platform.LarkSendMessageHandler;
import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler;
import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.config.WebThreadPoolConfiguration;
import cn.hippo4j.core.enable.MarkerConfiguration;
@ -46,6 +38,10 @@ import cn.hippo4j.core.springboot.starter.refresher.event.PlatformsListener;
import cn.hippo4j.core.springboot.starter.refresher.event.WebExecutorListener;
import cn.hippo4j.core.springboot.starter.support.DynamicThreadPoolPostProcessor;
import cn.hippo4j.core.springboot.starter.support.ThreadPoolAdapterRegister;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoSendMessageService;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.*;
@ -65,7 +61,7 @@ import org.springframework.core.annotation.Order;
@AllArgsConstructor
@ConditionalOnBean(MarkerConfiguration.Marker.class)
@EnableConfigurationProperties(BootstrapCoreProperties.class)
@ImportAutoConfiguration({UtilAutoConfiguration.class, WebThreadPoolConfiguration.class})
@ImportAutoConfiguration({UtilAutoConfiguration.class, MessageConfiguration.class, WebThreadPoolConfiguration.class})
@ConditionalOnProperty(prefix = BootstrapCoreProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
public class DynamicThreadPoolCoreAutoConfiguration {
@ -86,42 +82,16 @@ public class DynamicThreadPoolCoreAutoConfiguration {
return new ApplicationContextHolder();
}
@Bean
public AlarmControlHandler alarmControlHandler() {
return new AlarmControlHandler();
}
@Bean
public NotifyConfigBuilder notifyConfigBuilder(AlarmControlHandler alarmControlHandler) {
return new CoreNotifyConfigBuilder(alarmControlHandler, bootstrapCoreProperties);
}
@Bean
public HippoSendMessageService hippoSendMessageService(NotifyConfigBuilder notifyConfigBuilder,
AlarmControlHandler alarmControlHandler) {
return new HippoBaseSendMessageService(notifyConfigBuilder, alarmControlHandler);
}
@Bean
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(HippoSendMessageService hippoSendMessageService) {
return new ThreadPoolNotifyAlarmHandler(hippoSendMessageService);
}
@Bean
public SendMessageHandler dingSendMessageHandler() {
return new DingSendMessageHandler();
}
@Bean
public SendMessageHandler larkSendMessageHandler() {
return new LarkSendMessageHandler();
}
@Bean
public SendMessageHandler weChatSendMessageHandler() {
return new WeChatSendMessageHandler();
}
@Bean
public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor(ApplicationContextHolder hippo4JApplicationContextHolder) {
return new DynamicThreadPoolPostProcessor(bootstrapCoreProperties);

@ -17,7 +17,7 @@
package cn.hippo4j.core.springboot.starter.config;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.experimental.Accessors;

@ -17,14 +17,14 @@
package cn.hippo4j.core.springboot.starter.notify;
import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.common.notify.AlarmControlHandler;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.config.NotifyPlatformProperties;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

@ -17,13 +17,13 @@
package cn.hippo4j.core.springboot.starter.refresher;
import cn.hippo4j.common.notify.NotifyPlatformEnum;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.config.NotifyPlatformProperties;
import cn.hippo4j.message.enums.NotifyPlatformEnum;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.google.common.collect.Lists;

@ -17,8 +17,8 @@
package cn.hippo4j.core.springboot.starter.refresher;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import com.google.common.base.Charsets;
import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.CuratorFramework;

@ -17,7 +17,7 @@
package cn.hippo4j.core.springboot.starter.refresher.event;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;

@ -18,13 +18,13 @@
package cn.hippo4j.core.springboot.starter.refresher.event;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.notify.HippoBaseSendMessageService;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.springboot.starter.notify.CoreNotifyConfigBuilder;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.service.HippoBaseSendMessageService;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;

@ -18,7 +18,6 @@
package cn.hippo4j.core.springboot.starter.support;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.executor.DynamicThreadPool;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
@ -29,6 +28,7 @@ import cn.hippo4j.core.executor.support.*;
import cn.hippo4j.core.springboot.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.springboot.starter.config.ExecutorProperties;
import cn.hippo4j.core.toolkit.inet.DynamicThreadPoolAnnotationUtil;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;

@ -24,10 +24,15 @@ import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.config.WebThreadPoolConfiguration;
import cn.hippo4j.core.enable.MarkerConfiguration;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler;
import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.HippoSendMessageService;
import cn.hippo4j.springboot.starter.controller.ThreadPoolAdapterController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolController;
import cn.hippo4j.springboot.starter.controller.WebThreadPoolRunStateController;
@ -37,6 +42,7 @@ import cn.hippo4j.springboot.starter.monitor.ReportingEventExecutor;
import cn.hippo4j.springboot.starter.monitor.collect.RunTimeInfoCollector;
import cn.hippo4j.springboot.starter.monitor.send.MessageSender;
import cn.hippo4j.springboot.starter.monitor.send.http.HttpConnectSender;
import cn.hippo4j.springboot.starter.notify.ServerNotifyConfigBuilder;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import cn.hippo4j.springboot.starter.remote.HttpScheduledHealthCheck;
import cn.hippo4j.springboot.starter.remote.ServerHealthCheck;
@ -63,7 +69,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
@ConditionalOnBean(MarkerConfiguration.Marker.class)
@EnableConfigurationProperties(BootstrapProperties.class)
@ConditionalOnProperty(prefix = BootstrapProperties.PREFIX, value = "enable", matchIfMissing = true, havingValue = "true")
@ImportAutoConfiguration({HttpClientConfiguration.class, NettyClientConfiguration.class, DiscoveryConfiguration.class, MessageNotifyConfiguration.class, UtilAutoConfiguration.class,
@ImportAutoConfiguration({HttpClientConfiguration.class, NettyClientConfiguration.class, DiscoveryConfiguration.class, MessageConfiguration.class, UtilAutoConfiguration.class,
WebThreadPoolConfiguration.class})
public class DynamicThreadPoolAutoConfiguration {
@ -167,4 +173,21 @@ public class DynamicThreadPoolAutoConfiguration {
public ThreadPoolAdapterRegister threadPoolAdapterRegister(HttpAgent httpAgent, InetUtils hippo4JInetUtils) {
return new ThreadPoolAdapterRegister(httpAgent, properties, environment, hippo4JInetUtils);
}
@Bean
public NotifyConfigBuilder serverNotifyConfigBuilder(HttpAgent httpAgent,
BootstrapProperties properties,
AlarmControlHandler alarmControlHandler) {
return new ServerNotifyConfigBuilder(httpAgent, properties, alarmControlHandler);
}
@Bean
public ServerThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler) {
return new ServerThreadPoolDynamicRefresh(threadPoolNotifyAlarmHandler);
}
@Bean
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(HippoSendMessageService hippoSendMessageService) {
return new ThreadPoolNotifyAlarmHandler(hippoSendMessageService);
}
}

@ -1,83 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.springboot.starter.config;
import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.common.notify.*;
import cn.hippo4j.common.notify.platform.DingSendMessageHandler;
import cn.hippo4j.common.notify.platform.LarkSendMessageHandler;
import cn.hippo4j.common.notify.platform.WeChatSendMessageHandler;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;
import cn.hippo4j.springboot.starter.core.ServerThreadPoolDynamicRefresh;
import cn.hippo4j.springboot.starter.notify.ServerNotifyConfigBuilder;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
/**
* Message notify config.
*
* @author chen.ma
* @date 2021/8/15 15:39
*/
@AllArgsConstructor
public class MessageNotifyConfiguration {
@Bean
public AlarmControlHandler alarmControlHandler() {
return new AlarmControlHandler();
}
@Bean
public NotifyConfigBuilder notifyConfigBuilder(HttpAgent httpAgent,
BootstrapProperties properties,
AlarmControlHandler alarmControlHandler) {
return new ServerNotifyConfigBuilder(httpAgent, properties, alarmControlHandler);
}
@Bean
public HippoSendMessageService hippoSendMessageService(NotifyConfigBuilder notifyConfigBuilder,
AlarmControlHandler alarmControlHandler) {
return new HippoBaseSendMessageService(notifyConfigBuilder, alarmControlHandler);
}
@Bean
public ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler(HippoSendMessageService hippoSendMessageService) {
return new ThreadPoolNotifyAlarmHandler(hippoSendMessageService);
}
@Bean
public SendMessageHandler dingSendMessageHandler() {
return new DingSendMessageHandler();
}
@Bean
public SendMessageHandler larkSendMessageHandler() {
return new LarkSendMessageHandler();
}
@Bean
public SendMessageHandler weChatSendMessageHandler() {
return new WeChatSendMessageHandler();
}
@Bean
public ServerThreadPoolDynamicRefresh threadPoolDynamicRefresh(ThreadPoolNotifyAlarmHandler threadPoolNotifyAlarmHandler) {
return new ServerThreadPoolDynamicRefresh(threadPoolNotifyAlarmHandler);
}
}

@ -21,7 +21,6 @@ import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.enums.EnableEnum;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.core.executor.DynamicThreadPool;
@ -31,6 +30,7 @@ import cn.hippo4j.core.executor.manage.GlobalNotifyAlarmManage;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.*;
import cn.hippo4j.core.toolkit.inet.DynamicThreadPoolAnnotationUtil;
import cn.hippo4j.message.service.ThreadPoolNotifyAlarm;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import cn.hutool.core.util.BooleanUtil;

@ -20,7 +20,7 @@ package cn.hippo4j.springboot.starter.core;
import cn.hippo4j.common.enums.EnableEnum;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.common.notify.request.ChangeParameterNotifyRequest;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler;

@ -17,15 +17,15 @@
package cn.hippo4j.springboot.starter.notify;
import cn.hippo4j.common.notify.AlarmControlHandler;
import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.common.notify.ThreadPoolNotifyDTO;
import cn.hippo4j.common.notify.request.ThreadPoolNotifyRequest;
import cn.hippo4j.common.toolkit.GroupKey;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.dto.NotifyConfigDTO;
import cn.hippo4j.message.dto.ThreadPoolNotifyDTO;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.request.ThreadPoolNotifyRequest;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import cn.hutool.core.collection.CollUtil;

@ -19,6 +19,7 @@
<module>hippo4j-core</module>
<module>hippo4j-discovery</module>
<module>hippo4j-example</module>
<module>hippo4j-message</module>
<module>hippo4j-server</module>
<module>hippo4j-spring-boot</module>
<module>hippo4j-tool</module>
@ -102,6 +103,12 @@
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-message</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-config</artifactId>

Loading…
Cancel
Save