完善抽象消息模块.

pull/327/head
chen.ma 3 years ago
parent aa3bfa3267
commit 7c184f28ad

@ -1,31 +1,49 @@
package cn.hippo4j.common.notify; package cn.hippo4j.common.notify;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.util.Map;
/** /**
* Thread pool notify alarm. * Thread pool notify alarm.
* *
* @author chen.ma * @author chen.ma
* @date 2021/8/15 13:13 * @date 2021/8/15 19:13
*/ */
@Data @Data
@AllArgsConstructor @NoArgsConstructor
@RequiredArgsConstructor
public class ThreadPoolNotifyAlarm { public class ThreadPoolNotifyAlarm {
/** /**
* isAlarm * isAlarm
*/ */
@NonNull
private Boolean isAlarm; private Boolean isAlarm;
/** /**
* livenessAlarm * activeAlarm
*/ */
private Integer livenessAlarm; @NonNull
private Integer activeAlarm;
/** /**
* capacityAlarm * capacityAlarm
*/ */
@NonNull
private Integer capacityAlarm; private Integer capacityAlarm;
/**
* interval
*/
private Integer interval;
/**
* receives
*/
private Map<String, String> receives;
} }

@ -49,7 +49,7 @@ public class DingSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 实例信息 // 实例信息
alarmNotifyRequest.getIdentify(), alarmNotifyRequest.getIdentify(),
// 报警类型 // 报警类型
alarmNotifyRequest.getNotifyTypeEnum(), notifyConfig.getTypeEnum(),
// 核心线程数 // 核心线程数
alarmNotifyRequest.getCorePoolSize(), alarmNotifyRequest.getCorePoolSize(),
// 最大线程数 // 最大线程数
@ -63,7 +63,7 @@ public class DingSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 线程池任务总量 // 线程池任务总量
alarmNotifyRequest.getCompletedTaskCount(), alarmNotifyRequest.getCompletedTaskCount(),
// 队列类型名称 // 队列类型名称
alarmNotifyRequest.getClass().getSimpleName(), alarmNotifyRequest.getQueueName(),
// 队列容量 // 队列容量
alarmNotifyRequest.getCapacity(), alarmNotifyRequest.getCapacity(),
// 队列元素个数 // 队列元素个数
@ -77,7 +77,7 @@ public class DingSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 告警手机号 // 告警手机号
afterReceives, afterReceives,
// 报警频率 // 报警频率
alarmNotifyRequest.getInterval(), notifyConfig.getInterval(),
// 当前时间 // 当前时间
DateUtil.now() DateUtil.now()
); );

@ -49,7 +49,7 @@ public class LarkSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 实例信息 // 实例信息
alarmNotifyRequest.getIdentify(), alarmNotifyRequest.getIdentify(),
// 报警类型 // 报警类型
alarmNotifyRequest.getNotifyTypeEnum(), notifyConfig.getTypeEnum(),
// 核心线程数 // 核心线程数
alarmNotifyRequest.getCorePoolSize(), alarmNotifyRequest.getCorePoolSize(),
// 最大线程数 // 最大线程数
@ -63,7 +63,7 @@ public class LarkSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 线程池任务总量 // 线程池任务总量
alarmNotifyRequest.getCompletedTaskCount(), alarmNotifyRequest.getCompletedTaskCount(),
// 队列类型名称 // 队列类型名称
alarmNotifyRequest.getClass().getSimpleName(), alarmNotifyRequest.getQueueName(),
// 队列容量 // 队列容量
alarmNotifyRequest.getCapacity(), alarmNotifyRequest.getCapacity(),
// 队列元素个数 // 队列元素个数
@ -79,7 +79,7 @@ public class LarkSendMessageHandler implements SendMessageHandler<AlarmNotifyReq
// 当前时间 // 当前时间
DateUtil.now(), DateUtil.now(),
// 报警频率 // 报警频率
alarmNotifyRequest.getInterval() notifyConfig.getInterval()
); );
execute(notifyConfig.getSecretKey(), text); execute(notifyConfig.getSecretKey(), text);

@ -34,7 +34,7 @@ public class WeChatAlarmConstants {
"> 队列剩余个数:%s \n" + "> 队列剩余个数:%s \n" +
"> 拒绝策略:%s \n" + "> 拒绝策略:%s \n" +
"> 拒绝策略执行次数:%s \n" + "> 拒绝策略执行次数:%s \n" +
"> OWNER@%s \n" + "> OWNER<@%s> \n" +
"> 提示:%d 分钟内此线程池不会重复告警(可配置) \n\n" + "> 提示:%d 分钟内此线程池不会重复告警(可配置) \n\n" +
"**播报时间:%s**"; "**播报时间:%s**";

@ -32,7 +32,7 @@ public class WeChatSendMessageHandler implements SendMessageHandler<AlarmNotifyR
@Override @Override
public void sendAlarmMessage(NotifyConfigDTO notifyConfig, AlarmNotifyRequest alarmNotifyRequest) { public void sendAlarmMessage(NotifyConfigDTO notifyConfig, AlarmNotifyRequest alarmNotifyRequest) {
String[] receives = notifyConfig.getReceives().split(","); String[] receives = notifyConfig.getReceives().split(",");
String afterReceives = Joiner.on(", @").join(receives); String afterReceives = Joiner.on("><@").join(receives);
String text = String.format( String text = String.format(
WE_CHAT_ALARM_TXT, WE_CHAT_ALARM_TXT,
@ -59,7 +59,7 @@ public class WeChatSendMessageHandler implements SendMessageHandler<AlarmNotifyR
// 线程池任务总量 // 线程池任务总量
alarmNotifyRequest.getCompletedTaskCount(), alarmNotifyRequest.getCompletedTaskCount(),
// 队列类型名称 // 队列类型名称
alarmNotifyRequest.getClass().getSimpleName(), alarmNotifyRequest.getQueueName(),
// 队列容量 // 队列容量
alarmNotifyRequest.getCapacity(), alarmNotifyRequest.getCapacity(),
// 队列元素个数 // 队列元素个数

Loading…
Cancel
Save