Commit 6b6aada0 by 高鹏

Merge branch 'ruansiyuan' into 'master'

群发做1s延时,改为异步

See merge request rays/pcloud-book!118
parents 29091089 3da09d71
......@@ -265,8 +265,8 @@ public class PushBizImpl implements PushBiz {
pushRecord.setPushStatus(PushStatusEnum.PUSHING.value);
//新增群发记录
pushRecordDao.insert(pushRecord);
//新增细化到群的记录并发送消息
addPushGroupRecordsAndSend(pushGroupList, pushRecord, pushItemList);
//新增细化到群的记录并发送消息,异步
ThreadPoolUtils.SEND_MESSAGE_THREAD_POOL.execute(() -> addPushGroupRecordsAndSend(pushGroupList, pushRecord, pushItemList));
} catch (Exception e) {
LOGGER.error(e.getMessage(), "群发消息失败!"+e);
pushRecordDao.updateStateById(pushRecord.getId(), PushStatusEnum.FAIL.value);
......@@ -299,7 +299,15 @@ public class PushBizImpl implements PushBiz {
String altId = wechatGroupConsr.getRobotIdByGroupId(groupQrcode.getWeixinGroupId());
//遍历发送消息
for (PushItem pushItem : pushItemList) {
sendWechatMessage(pushGroup, pushItem, pushGroupRecord.getId(), altId);
try {
LOGGER.info("发送一个群里的一个消息开始pushGroup=" + pushGroup.toString() + "pushItem=" + pushItem.toString() + "altId=" + altId);
sendWechatMessage(pushGroup, pushItem, pushGroupRecord.getId(), altId);
LOGGER.info("发送一个群里的一个消息结束,休眠1秒pushGroup=" + pushGroup.toString() + "pushItem=" + pushItem.toString() + "altId=" + altId);
Thread.sleep(1000);
} catch (InterruptedException e) {
LOGGER.error("发消息休眠1秒出错", e);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment