update 优化 websocket 服务不存在异常逻辑处理

2.X
疯狂的狮子Li 1 year ago
parent 717c7b2873
commit f6252a80cd

@ -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; private final RemoteClientService remoteClientService;
@DubboReference @DubboReference
private final RemoteSocialService remoteSocialService; private final RemoteSocialService remoteSocialService;
@DubboReference @DubboReference(stub = "true")
private final RemoteMessageService remoteMessageService; private final RemoteMessageService remoteMessageService;
/** /**
@ -97,10 +97,7 @@ public class TokenController {
Long userId = LoginHelper.getUserId(); Long userId = LoginHelper.getUserId();
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
try { remoteMessageService.sendMessage(userId, "欢迎登录RuoYi-Cloud-Plus微服务管理系统");
remoteMessageService.sendMessage(userId, "欢迎登录RuoYi-Cloud-Plus微服务管理系统");
} catch (Exception ignored) {
}
}, 3, TimeUnit.SECONDS); }, 3, TimeUnit.SECONDS);
return R.ok(loginVo); return R.ok(loginVo);
} }

Loading…
Cancel
Save