同步获取响应数据

This commit is contained in:
Guoqs
2024-08-01 16:24:52 +08:00
parent 201137bb9f
commit 901310f061
9 changed files with 61 additions and 307 deletions

View File

@@ -10,6 +10,7 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.*;
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
import com.jsowell.pile.domain.ykcCommond.*;
import com.jsowell.pile.rpc.RpcUtil;
import com.jsowell.pile.rpc.SyncPromise;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.web.BillingTemplateVO;
@@ -41,7 +42,6 @@ import java.util.concurrent.TimeoutException;
@Slf4j
@Service
public class YKCPushCommandServiceImpl implements YKCPushCommandService {
private final static Map<String, SyncPromise> syncPromiseMap = new ConcurrentHashMap<>();
@Autowired
private PileBillingTemplateService pileBillingTemplateService;
@@ -162,8 +162,8 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
// 消息id = channelId + 帧类型(例如: "0x34")
String msgId = ctx.channel().id().toString() + "_" + YKCUtils.frameType2Str(((YKCFrameTypeCode) frameTypeCode).getBytes());
syncPromiseMap.put(msgId, syncPromise);
log.info("同步获取响应数据-发送消息, msgId:{}", msgId);
RpcUtil.getSyncPromiseMap().put(msgId, syncPromise);
// 发送消息此处如果发送玩消息并且在get之前返回了结果下一行的get将不会进入阻塞也可以顺利拿到结果
/*
@@ -223,7 +223,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
}
// 移除容器
syncPromiseMap.remove(msgId);
RpcUtil.getSyncPromiseMap().remove(msgId);
return rpcResponse;
}