mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 11:05:58 +00:00
update 优化 websocket 服务不存在异常逻辑处理
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 消息服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||
|
||||
private final RemoteMessageService remoteMessageService;
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param sessionKey session主键 一般为用户id
|
||||
* @param message 消息文本
|
||||
*/
|
||||
public void sendMessage(Long sessionKey, String message) {
|
||||
try {
|
||||
remoteMessageService.sendMessage(sessionKey, message);
|
||||
} catch (Exception e) {
|
||||
log.warn("websocket 功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
public void publishAll(String message) {
|
||||
try {
|
||||
remoteMessageService.publishAll(message);
|
||||
} catch (Exception e) {
|
||||
log.warn("websocket 功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
}
|
@@ -65,7 +65,7 @@ public class TokenController {
|
||||
private final RemoteClientService remoteClientService;
|
||||
@DubboReference
|
||||
private final RemoteSocialService remoteSocialService;
|
||||
@DubboReference
|
||||
@DubboReference(stub = "true")
|
||||
private final RemoteMessageService remoteMessageService;
|
||||
|
||||
/**
|
||||
@@ -97,10 +97,7 @@ public class TokenController {
|
||||
|
||||
Long userId = LoginHelper.getUserId();
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
try {
|
||||
remoteMessageService.sendMessage(userId, "欢迎登录RuoYi-Cloud-Plus微服务管理系统");
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
remoteMessageService.sendMessage(userId, "欢迎登录RuoYi-Cloud-Plus微服务管理系统");
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
return R.ok(loginVo);
|
||||
}
|
||||
|
Reference in New Issue
Block a user