Commit 3da09d71 by 阮思源

群发的地方设置为异步并延时1s

parent b710ea5c
...@@ -265,8 +265,8 @@ public class PushBizImpl implements PushBiz { ...@@ -265,8 +265,8 @@ public class PushBizImpl implements PushBiz {
pushRecord.setPushStatus(PushStatusEnum.PUSHING.value); pushRecord.setPushStatus(PushStatusEnum.PUSHING.value);
//新增群发记录 //新增群发记录
pushRecordDao.insert(pushRecord); pushRecordDao.insert(pushRecord);
//新增细化到群的记录并发送消息 //新增细化到群的记录并发送消息,异步
addPushGroupRecordsAndSend(pushGroupList, pushRecord, pushItemList); ThreadPoolUtils.SEND_MESSAGE_THREAD_POOL.execute(() -> addPushGroupRecordsAndSend(pushGroupList, pushRecord, pushItemList));
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(e.getMessage(), "群发消息失败!"+e); LOGGER.error(e.getMessage(), "群发消息失败!"+e);
pushRecordDao.updateStateById(pushRecord.getId(), PushStatusEnum.FAIL.value); pushRecordDao.updateStateById(pushRecord.getId(), PushStatusEnum.FAIL.value);
...@@ -299,7 +299,15 @@ public class PushBizImpl implements PushBiz { ...@@ -299,7 +299,15 @@ public class PushBizImpl implements PushBiz {
String altId = wechatGroupConsr.getRobotIdByGroupId(groupQrcode.getWeixinGroupId()); String altId = wechatGroupConsr.getRobotIdByGroupId(groupQrcode.getWeixinGroupId());
//遍历发送消息 //遍历发送消息
for (PushItem pushItem : pushItemList) { 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