public virtual async Task Process(IChannelHandlerContext ctx, RpcMessage rpcMessage) { if (rpcMessage.Body is MergeResultMessage results) { if (mergeMsgMap != null && mergeMsgMap.TryGetValue(rpcMessage.Id, out IMergeMessage mergeMessageData)) { var mergeMessage = (MergedWarpMessage)mergeMessageData; for (int i = 0; i < mergeMessage.msgs.Count; i++) { int msgId = mergeMessage.msgIds[i]; if (!futures.TryRemove(msgId, out MessageFuture future) || future == null) { if (Logger().IsEnabled(level: LogLevel.Debug)) { Logger().LogInformation($"msg: {msgId} is not found in futures."); } } else { future.ResultMessage = results.Msgs[i]; } } } } else { if (futures.TryRemove(rpcMessage.Id, out MessageFuture messageFuture) && messageFuture != null) { messageFuture.ResultMessage = rpcMessage.Body; } else { if (rpcMessage.Body is AbstractResultMessage result) { if (transactionMessageHandler != null) { await transactionMessageHandler.OnResponse(result, null); } } } } }
private async Task OnResponseMessage(IChannelHandlerContext ctx, RpcMessage rpcMessage) { if (Logger().IsEnabled(LogLevel.Debug)) { Logger().LogDebug($"server received:{rpcMessage.Body},clientIp:{NetUtil.ToIpAddress(ctx.Channel.RemoteAddress)},vgroup:{ChannelManager.GetContextFromIdentified(ctx.Channel).TransactionServiceGroup}"); } else { try { BatchLogHandler.INSTANCE.LogQueue.Add($"{rpcMessage.Body},clientIp:{NetUtil.ToIpAddress(ctx.Channel.RemoteAddress)},vgroup:{ChannelManager.GetContextFromIdentified(ctx.Channel).TransactionServiceGroup}"); } catch (Exception e) { Logger().LogError(e, $"put message to logQueue error: {e.Message}"); } } if (rpcMessage.Body is AbstractResultMessage abstractResultMessage) { RpcContext rpcContext = ChannelManager.GetContextFromIdentified(ctx.Channel); await _transactionMessageHandler.OnResponse(abstractResultMessage, rpcContext); } }