USVT-135 尝试使用异步的方式来尝试回复消息
This commit is contained in:
parent
96e5f0ff56
commit
abd06dc190
|
@ -166,7 +166,7 @@ public class WeChatService {
|
|||
};
|
||||
Future<Object> future = executor.submit(task);
|
||||
try {
|
||||
Object result = future.get(15, TimeUnit.SECONDS);
|
||||
Object result = future.get(3, TimeUnit.SECONDS);
|
||||
contentGPT = (String) result;
|
||||
} catch (TimeoutException ex) {
|
||||
contentGPT = "ChatGPT API Time out, Please Re-try it";
|
||||
|
@ -178,18 +178,18 @@ public class WeChatService {
|
|||
future.cancel(true); // may or may not desire this
|
||||
}
|
||||
|
||||
// try {
|
||||
// sendMessage(toUserName);
|
||||
// } catch (WxErrorException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
try {
|
||||
sendMessage(toUserName);
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
weChatMessage.setToUserName(toUserName);
|
||||
weChatMessage.setFromUserName(fromUserName);
|
||||
weChatMessage.setContent(contentGPT);
|
||||
weChatMessage.setCreateTime(Instant.now().toEpochMilli());
|
||||
// weChatMessage.setToUserName(toUserName);
|
||||
// weChatMessage.setFromUserName(fromUserName);
|
||||
// weChatMessage.setContent(contentGPT);
|
||||
// weChatMessage.setCreateTime(Instant.now().toEpochMilli());
|
||||
|
||||
return WeChatUtils.covertToWeChatMessageXmlStr(weChatMessage);
|
||||
return "success";// WeChatUtils.covertToWeChatMessageXmlStr(weChatMessage);
|
||||
}
|
||||
|
||||
public String sendMessage(String toUserName) throws WxErrorException {
|
||||
|
|
|
@ -89,7 +89,7 @@ wechat:
|
|||
token: 0b01a700891d4a2f93a4323771c32455
|
||||
aes-key: 1IG2Xd7UykSga2jgrFFQrQCGFWilvO01hPyXRqS8mMI
|
||||
official-account:
|
||||
app-id: wx6362d43a5e29ec3c
|
||||
secret: 62f6d9a34acbfa1da1977de0057ad4f9
|
||||
app-id: wx130a621cd242fec4
|
||||
secret: 1a61321790b8d32fc96b6260ecc712fa
|
||||
token: 0b01a700891d4a2f93a4323771c32455
|
||||
aes-key: 1IG2Xd7UykSga2jgrFFQrQCGFWilvO01hPyXRqS8mMI
|
||||
|
|
Loading…
Reference in New Issue