fix:2.5.0
1. 修复钉钉发送失败问题 2. 客户端异常信息添加空间ID 3. 修复告警阈值没有匹配最大重试次数问题
This commit is contained in:
parent
9d553ab2c1
commit
8e9eafb4c8
@ -47,9 +47,10 @@ public class EasyRetryInterceptor implements MethodInterceptor, AfterAdvice, Ser
|
|||||||
|
|
||||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
private static String retryErrorMoreThresholdTextMessageFormatter =
|
private static String retryErrorMoreThresholdTextMessageFormatter =
|
||||||
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试组件异常</font> \r\n" +
|
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试组件异常</font> \n" +
|
||||||
"> 名称:{} \r\n" +
|
"> 空间ID:{} \n" +
|
||||||
"> 时间:{} \r\n" +
|
"> 名称:{} \n" +
|
||||||
|
"> 时间:{} \n" +
|
||||||
"> 异常:{} \n";
|
"> 异常:{} \n";
|
||||||
|
|
||||||
private final StandardEnvironment standardEnvironment;
|
private final StandardEnvironment standardEnvironment;
|
||||||
@ -204,6 +205,7 @@ public class EasyRetryInterceptor implements MethodInterceptor, AfterAdvice, Ser
|
|||||||
AlarmContext context = AlarmContext.build()
|
AlarmContext context = AlarmContext.build()
|
||||||
.text(retryErrorMoreThresholdTextMessageFormatter,
|
.text(retryErrorMoreThresholdTextMessageFormatter,
|
||||||
EnvironmentUtils.getActiveProfile(),
|
EnvironmentUtils.getActiveProfile(),
|
||||||
|
standardEnvironment.getProperty("easy-retry.namespace", StrUtil.EMPTY),
|
||||||
EasyRetryProperties.getGroup(),
|
EasyRetryProperties.getGroup(),
|
||||||
LocalDateTime.now().format(formatter),
|
LocalDateTime.now().format(formatter),
|
||||||
e.getMessage())
|
e.getMessage())
|
||||||
|
@ -40,9 +40,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class ReportListener implements Listener<RetryTaskDTO> {
|
public class ReportListener implements Listener<RetryTaskDTO> {
|
||||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
private static String reportErrorTextMessageFormatter =
|
private static String reportErrorTextMessageFormatter =
|
||||||
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 上报失败</font> \r\n" +
|
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 异步批量上报异常</font> \n" +
|
||||||
"> 名称:{} \r\n" +
|
"> 空间ID:{} n" +
|
||||||
"> 时间:{} \r\n" +
|
"> 名称:{} \n" +
|
||||||
|
"> 时间:{} \n" +
|
||||||
"> 异常:{} \n"
|
"> 异常:{} \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -106,10 +107,15 @@ public class ReportListener implements Listener<RetryTaskDTO> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ConfigDTO.Notify notifyAttribute = GroupVersionCache.getNotifyAttribute(NotifySceneEnum.CLIENT_REPORT_ERROR.getNotifyScene());
|
ConfigDTO.Notify notifyAttribute = GroupVersionCache.getNotifyAttribute(NotifySceneEnum.CLIENT_REPORT_ERROR.getNotifyScene());
|
||||||
if (Objects.nonNull(notifyAttribute)) {
|
if (Objects.isNull(notifyAttribute)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyRetryProperties properties = SpringContext.CONTEXT.getBean(EasyRetryProperties.class);
|
||||||
AlarmContext context = AlarmContext.build()
|
AlarmContext context = AlarmContext.build()
|
||||||
.text(reportErrorTextMessageFormatter,
|
.text(reportErrorTextMessageFormatter,
|
||||||
EnvironmentUtils.getActiveProfile(),
|
EnvironmentUtils.getActiveProfile(),
|
||||||
|
properties.getNamespace(),
|
||||||
EasyRetryProperties.getGroup(),
|
EasyRetryProperties.getGroup(),
|
||||||
LocalDateTime.now().format(formatter),
|
LocalDateTime.now().format(formatter),
|
||||||
e.getMessage())
|
e.getMessage())
|
||||||
@ -119,7 +125,6 @@ public class ReportListener implements Listener<RetryTaskDTO> {
|
|||||||
EasyRetryAlarmFactory easyRetryAlarmFactory = SpringContext.getBeanByType(EasyRetryAlarmFactory.class);
|
EasyRetryAlarmFactory easyRetryAlarmFactory = SpringContext.getBeanByType(EasyRetryAlarmFactory.class);
|
||||||
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyAttribute.getNotifyType());
|
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyAttribute.getNotifyType());
|
||||||
alarmType.asyncSendMessage(context);
|
alarmType.asyncSendMessage(context);
|
||||||
}
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
LogUtils.error(log, "客户端发送组件异常告警失败", e1);
|
LogUtils.error(log, "客户端发送组件异常告警失败", e1);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,29 @@
|
|||||||
package com.aizuda.easy.retry.client.core.report;
|
package com.aizuda.easy.retry.client.core.report;
|
||||||
|
|
||||||
|
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||||
|
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||||
import com.aizuda.easy.retry.client.core.client.NettyClient;
|
import com.aizuda.easy.retry.client.core.client.NettyClient;
|
||||||
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||||
|
import com.aizuda.easy.retry.common.core.alarm.Alarm;
|
||||||
|
import com.aizuda.easy.retry.common.core.alarm.AlarmContext;
|
||||||
|
import com.aizuda.easy.retry.common.core.alarm.EasyRetryAlarmFactory;
|
||||||
|
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||||
|
import com.aizuda.easy.retry.common.core.enums.NotifySceneEnum;
|
||||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||||
|
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
||||||
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +37,19 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class SyncReport extends AbstractReport {
|
public class SyncReport extends AbstractReport {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
private static String reportErrorTextMessageFormatter =
|
||||||
|
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 同步上报异常</font> \n" +
|
||||||
|
"> 空间ID:{} \n" +
|
||||||
|
"> 名称:{} \n" +
|
||||||
|
"> 时间:{} \n" +
|
||||||
|
"> 异常:{} \n"
|
||||||
|
;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EasyRetryProperties easyRetryProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(boolean async) {
|
public boolean supports(boolean async) {
|
||||||
return !async;
|
return !async;
|
||||||
@ -49,11 +75,42 @@ public class SyncReport extends AbstractReport {
|
|||||||
.unit(unit)
|
.unit(unit)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
NettyResult result = client.reportRetryInfo(Collections.singletonList(retryTaskDTO));
|
NettyResult result = client.reportRetryInfo(Collections.singletonList(retryTaskDTO));
|
||||||
LogUtils.debug(log, "Data report result result:[{}]", JsonUtil.toJsonString(result));
|
LogUtils.debug(log, "Data report result result:[{}]", JsonUtil.toJsonString(result));
|
||||||
|
|
||||||
return (Boolean) result.getData();
|
return (Boolean) result.getData();
|
||||||
|
} catch (Exception e) {
|
||||||
|
sendMessage(e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(Throwable e) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
ConfigDTO.Notify notifyAttribute = GroupVersionCache.getNotifyAttribute(NotifySceneEnum.CLIENT_REPORT_ERROR.getNotifyScene());
|
||||||
|
if (Objects.isNull(notifyAttribute)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlarmContext context = AlarmContext.build()
|
||||||
|
.text(reportErrorTextMessageFormatter,
|
||||||
|
EnvironmentUtils.getActiveProfile(),
|
||||||
|
easyRetryProperties.getNamespace(),
|
||||||
|
EasyRetryProperties.getGroup(),
|
||||||
|
LocalDateTime.now().format(formatter),
|
||||||
|
e.getMessage())
|
||||||
|
.title("同步上报异常:[{}]", EasyRetryProperties.getGroup())
|
||||||
|
.notifyAttribute(notifyAttribute.getNotifyAttribute());
|
||||||
|
|
||||||
|
EasyRetryAlarmFactory easyRetryAlarmFactory = SpringContext.getBeanByType(EasyRetryAlarmFactory.class);
|
||||||
|
Alarm<AlarmContext> alarmType = easyRetryAlarmFactory.getAlarmType(notifyAttribute.getNotifyType());
|
||||||
|
alarmType.asyncSendMessage(context);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
LogUtils.error(log, "客户端发送组件异常告警失败", e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,10 @@ import java.util.function.Consumer;
|
|||||||
public abstract class AbstractRetryStrategies implements RetryStrategy {
|
public abstract class AbstractRetryStrategies implements RetryStrategy {
|
||||||
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
private static String retryErrorMoreThresholdTextMessageFormatter =
|
private static String retryErrorMoreThresholdTextMessageFormatter =
|
||||||
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试组件异常</font> \r\n" +
|
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试期间发生非预期异常</font> \n" +
|
||||||
"> 名称:{} \r\n" +
|
"> 空间ID:{} \n" +
|
||||||
"> 时间:{} \r\n" +
|
"> 名称:{} \n" +
|
||||||
|
"> 时间:{} \n" +
|
||||||
"> 异常:{} \n"
|
"> 异常:{} \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -52,6 +53,8 @@ public abstract class AbstractRetryStrategies implements RetryStrategy {
|
|||||||
private EasyRetryAlarmFactory easyRetryAlarmFactory;
|
private EasyRetryAlarmFactory easyRetryAlarmFactory;
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<Report> reports;
|
private List<Report> reports;
|
||||||
|
@Autowired
|
||||||
|
private EasyRetryProperties easyRetryProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RetryerResultContext openRetry(String sceneName, String executorClassName, Object[] params) {
|
public RetryerResultContext openRetry(String sceneName, String executorClassName, Object[] params) {
|
||||||
@ -176,6 +179,7 @@ public abstract class AbstractRetryStrategies implements RetryStrategy {
|
|||||||
AlarmContext context = AlarmContext.build()
|
AlarmContext context = AlarmContext.build()
|
||||||
.text(retryErrorMoreThresholdTextMessageFormatter,
|
.text(retryErrorMoreThresholdTextMessageFormatter,
|
||||||
EnvironmentUtils.getActiveProfile(),
|
EnvironmentUtils.getActiveProfile(),
|
||||||
|
easyRetryProperties.getNamespace(),
|
||||||
EasyRetryProperties.getGroup(),
|
EasyRetryProperties.getGroup(),
|
||||||
LocalDateTime.now().format(formatter),
|
LocalDateTime.now().format(formatter),
|
||||||
e.getMessage())
|
e.getMessage())
|
||||||
|
@ -53,8 +53,8 @@ public class DingDingUtils {
|
|||||||
request.setMsgtype("markdown");
|
request.setMsgtype("markdown");
|
||||||
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
||||||
markdown.setTitle(title);
|
markdown.setTitle(title);
|
||||||
request.setMarkdown(markdown);
|
|
||||||
markdown.setText(subTextLength(getAtText(ats, text)));
|
markdown.setText(subTextLength(getAtText(ats, text)));
|
||||||
|
request.setMarkdown(markdown);
|
||||||
|
|
||||||
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||||
at.setAtMobiles(ats);
|
at.setAtMobiles(ats);
|
||||||
@ -81,9 +81,10 @@ public class DingDingUtils {
|
|||||||
public static boolean sendMessage(OapiRobotSendRequest request, String url) {
|
public static boolean sendMessage(OapiRobotSendRequest request, String url) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (StrUtil.isNotBlank(url)) {
|
if (StrUtil.isBlank(url)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DingTalkClient client = new DefaultDingTalkClient(url);
|
DingTalkClient client = new DefaultDingTalkClient(url);
|
||||||
client.execute(request);
|
client.execute(request);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public abstract class AbstractAlarm<E extends ApplicationEvent, A extends AlarmI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Objects.nonNull(alarmDTO.getCount()) && Objects.nonNull(notifyConfig.getNotifyThreshold())) {
|
if (Objects.nonNull(alarmDTO.getCount()) && Objects.nonNull(notifyConfig.getNotifyThreshold())) {
|
||||||
if (notifyConfig.getNotifyThreshold() > alarmDTO.getCount()) {
|
if (notifyConfig.getNotifyThreshold() >= alarmDTO.getCount()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/scene-config")
|
@RequestMapping("/scene-config")
|
||||||
public class SceneConfigSceneController {
|
public class SceneConfigController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SceneConfigService sceneConfigService;
|
private SceneConfigService sceneConfigService;
|
@ -67,7 +67,7 @@ public class SceneConfigServiceImpl implements SceneConfigService {
|
|||||||
|
|
||||||
List<SceneConfig> sceneConfigs = accessTemplate.getSceneConfigAccess()
|
List<SceneConfig> sceneConfigs = accessTemplate.getSceneConfigAccess()
|
||||||
.list(new LambdaQueryWrapper<SceneConfig>()
|
.list(new LambdaQueryWrapper<SceneConfig>()
|
||||||
.select(SceneConfig::getSceneName, SceneConfig::getDescription)
|
.select(SceneConfig::getSceneName, SceneConfig::getDescription, SceneConfig::getMaxRetryCount)
|
||||||
.eq(SceneConfig::getNamespaceId, namespaceId)
|
.eq(SceneConfig::getNamespaceId, namespaceId)
|
||||||
.eq(SceneConfig::getGroupName, groupName)
|
.eq(SceneConfig::getGroupName, groupName)
|
||||||
.orderByDesc(SceneConfig::getCreateDt));
|
.orderByDesc(SceneConfig::getCreateDt));
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
v-else
|
v-else
|
||||||
id="inputNumber"
|
id="inputNumber"
|
||||||
:min="1"
|
:min="1"
|
||||||
|
:max="maxNotifyThreshold"
|
||||||
style="width: -webkit-fill-available"
|
style="width: -webkit-fill-available"
|
||||||
v-decorator="[
|
v-decorator="[
|
||||||
'notifyThreshold',
|
'notifyThreshold',
|
||||||
@ -63,8 +64,8 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :lg="6" :md="12" :sm="24">
|
<a-col :lg="6" :md="12" :sm="24">
|
||||||
<a-form-item label="场景">
|
<a-form-item label="场景">
|
||||||
<a-select :disabled="sceneNameDisabled.includes(this.notifySceneValue)" placeholder="请选择场景" v-decorator="['sceneName', { rules: [{ required: !sceneNameDisabled.includes(this.notifySceneValue), message: '请选择场景' }] }]" >
|
<a-select :disabled="sceneNameDisabled.includes(this.notifySceneValue)" placeholder="请选择场景" v-decorator="['sceneName', { rules: [{ required: !sceneNameDisabled.includes(this.notifySceneValue), message: '请选择场景' }] }]" @select="changeSceneName">
|
||||||
<a-select-option v-for="item in sceneList" :value="item.sceneName" :key="item.sceneName">{{ item.sceneName }}</a-select-option>
|
<a-select-option v-for="item in sceneList" :value="item.sceneName" :maxRetryCount="item.maxRetryCount" :key="item.sceneName">{{ item.sceneName }}</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@ -321,7 +322,8 @@ export default {
|
|||||||
notifySceneValue: '1',
|
notifySceneValue: '1',
|
||||||
rateLimiterStatusValue: '0',
|
rateLimiterStatusValue: '0',
|
||||||
defaultRateLimiterStatusValue: '0',
|
defaultRateLimiterStatusValue: '0',
|
||||||
defaultRateLimiterThreshold: '100'
|
defaultRateLimiterThreshold: '100',
|
||||||
|
maxNotifyThreshold: 999
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeCreate () {
|
beforeCreate () {
|
||||||
@ -365,6 +367,9 @@ export default {
|
|||||||
this.sceneList = res.data
|
this.sceneList = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
changeSceneName (value, option) {
|
||||||
|
this.maxNotifyThreshold = option.data.attrs.maxRetryCount
|
||||||
|
},
|
||||||
changeRateLimiterStatus (rateLimiterStatus) {
|
changeRateLimiterStatus (rateLimiterStatus) {
|
||||||
this.rateLimiterStatusValue = rateLimiterStatus
|
this.rateLimiterStatusValue = rateLimiterStatus
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user