mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-01 19:38:09 +08:00
节点升级 socket 锁调整
This commit is contained in:
parent
410637e1eb
commit
33eb189ab0
@ -63,7 +63,7 @@ public class NodeClient extends WebSocketClient {
|
||||
public void onMessage(String message) {
|
||||
try {
|
||||
// 不能并发向同一个客户端发送消息 @author jzy 2021-08-03
|
||||
synchronized (NodeUpdateHandler.class) {
|
||||
synchronized (session.getId()) {
|
||||
session.sendMessage(new TextMessage(message));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -71,12 +71,14 @@ public class NodeUpdateHandler extends BaseProxyHandler {
|
||||
Map<String, Object> attributes = session.getAttributes();
|
||||
String url = NodeForward.getSocketUrl(model, NodeUrl.NodeUpdate, (UserModel) attributes.get("userInfo"));
|
||||
// 连接节点
|
||||
try {
|
||||
NodeClient client = new NodeClient(url, model, session);
|
||||
clientMap.put(model.getId(), client);
|
||||
} catch (Exception e) {
|
||||
DefaultSystemLog.getLog().error("创建插件端连接失败", e);
|
||||
}
|
||||
ThreadUtil.execute(() -> {
|
||||
try {
|
||||
NodeClient client = new NodeClient(url, model, session);
|
||||
clientMap.put(model.getId(), client);
|
||||
} catch (Exception e) {
|
||||
DefaultSystemLog.getLog().error("创建插件端连接失败", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +192,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
|
||||
|
||||
private void sendMsg(WebSocketMessageModel model, WebSocketSession session) {
|
||||
try {
|
||||
synchronized (NodeUpdateHandler.class) {
|
||||
synchronized (session.getId()) {
|
||||
session.sendMessage(new TextMessage(model.toString()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user