|
|
@@ -1678,12 +1678,35 @@ public class Task {
|
|
|
return;
|
|
|
}
|
|
|
for (Map.Entry<String, BatchSendCourseAllDTO> entry : toSendMap) {
|
|
|
+ String key=entry.getKey();
|
|
|
//执行发送消息任务
|
|
|
BatchSendCourseAllDTO batchSendCourseAllDTO = entry.getValue();
|
|
|
- openIMService.batchSendCourseTask(batchSendCourseAllDTO.getBatchSendCourseDTO(), batchSendCourseAllDTO.getOpenImBatchMsgDTO(), batchSendCourseAllDTO.getProject(), batchSendCourseAllDTO.getImMsgSendDetailList());
|
|
|
+ OpenImBatchMsgDTO openImBatchMsgDTO = batchSendCourseAllDTO.getOpenImBatchMsgDTO();
|
|
|
+ Integer nowCount=openImBatchMsgDTO.getCount();
|
|
|
+ OpenImResponseDTO responseDTO=new OpenImResponseDTO();
|
|
|
+ try {
|
|
|
+ responseDTO= openIMService.batchSendCourseTask(batchSendCourseAllDTO.getBatchSendCourseDTO(), batchSendCourseAllDTO.getOpenImBatchMsgDTO(), batchSendCourseAllDTO.getProject(), batchSendCourseAllDTO.getImMsgSendDetailList());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+
|
|
|
+ if(nowCount<3){ // 重试三次后放弃
|
|
|
+ logger.error("重试三次后放弃,key{}", entry.getKey());
|
|
|
+ redisTemplate.opsForHash().delete(redisKey, entry.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(responseDTO!=null && responseDTO.getErrCode() == 0){
|
|
|
+ // 执行结束,删除
|
|
|
+ redisTemplate.opsForHash().delete(redisKey, entry.getKey());
|
|
|
+ }else {
|
|
|
+ openImBatchMsgDTO.setCount(openImBatchMsgDTO.getCount() + 1);// 次数加一
|
|
|
+ batchSendCourseAllDTO.setOpenImBatchMsgDTO(openImBatchMsgDTO);
|
|
|
+ // 错误更新次数 重新放入redis中
|
|
|
+ redisTemplate.opsForHash().put(redisKey, key, batchSendCourseAllDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- // 执行结束,删除
|
|
|
- this.redisTemplate.<String, BatchSendCourseAllDTO>opsForHash().delete(redisKey, entry.getKey());
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1711,17 +1734,33 @@ public class Task {
|
|
|
return;
|
|
|
}
|
|
|
for (Map.Entry<String, BatchSendCourseAllDTO> entry : toSendMap) {
|
|
|
+ String key=entry.getKey();
|
|
|
//执行发送消息任务
|
|
|
BatchSendCourseAllDTO batchSendCourseAllDTO = entry.getValue();
|
|
|
+ OpenImBatchMsgDTO openImBatchMsgDTO = batchSendCourseAllDTO.getOpenImBatchMsgDTO();
|
|
|
+ Integer nowCount=openImBatchMsgDTO.getCount();
|
|
|
+ OpenImResponseDTO responseDTO=new OpenImResponseDTO();
|
|
|
try {
|
|
|
openIMService.batchUrgeCourseTask(batchSendCourseAllDTO.getOpenImBatchMsgDTO(), batchSendCourseAllDTO.getImMsgSendDetailList());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 执行结束,删除
|
|
|
- this.redisTemplate.<String, BatchSendCourseAllDTO>opsForHash().delete(redisKey, entry.getKey());
|
|
|
+ }finally {
|
|
|
|
|
|
+ if(nowCount<3){ // 重试三次后放弃
|
|
|
+ logger.error("重试三次后放弃,key{}", entry.getKey());
|
|
|
+ redisTemplate.opsForHash().delete(redisKey, entry.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(responseDTO!=null && responseDTO.getErrCode() == 0){
|
|
|
+ // 执行结束,删除
|
|
|
+ redisTemplate.opsForHash().delete(redisKey, entry.getKey());
|
|
|
+ }else {
|
|
|
+ openImBatchMsgDTO.setCount(openImBatchMsgDTO.getCount() + 1);// 次数加一
|
|
|
+ batchSendCourseAllDTO.setOpenImBatchMsgDTO(openImBatchMsgDTO);
|
|
|
+ // 错误更新次数 重新放入redis中
|
|
|
+ redisTemplate.opsForHash().put(redisKey, key, batchSendCourseAllDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|