public async Task <RpcResult <VoidRes> > ExcuteAsync(CommonReq req, int timeOut = 3000)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(2000, 1);

            message.FriendlyServiceName = "TaskConsumerService.Excute";
            message.Data = req.ToByteArray();
            var response = await base.CallInvoker.AsyncCall(message, timeOut);

            if (response == null)
            {
                throw new RpcException("error,response is null !");
            }
            var result = new RpcResult <VoidRes>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }
            else if (response.Data == null)
            {
                result.Code = ErrorCodes.CODE_INTERNAL_ERROR;
            }
            else
            {
                result.Data = VoidRes.Parser.ParseFrom(response.Data);
            }

            return(result);
        }
Exemple #2
0
        //调用委托
        private async Task <AmpMessage> ProcessExcuteAsync(AmpMessage req)
        {
            CommonReq request = null;

            if (req.Data == null)
            {
                request = new CommonReq();
            }
            else
            {
                request = CommonReq.Parser.ParseFrom(req.Data);
            }

            req.FriendlyServiceName = "TaskConsumerService.Excute";

            var result = await ExcuteAsync(request);

            var response = AmpMessage.CreateResponseMessage(req.ServiceId, req.MessageId);

            response.FriendlyServiceName = "TaskConsumerService.Excute";
            response.Code = result.Code;
            if (result.Data != null)
            {
                response.Data = result.Data.ToByteArray();
            }
            return(response);
        }
Exemple #3
0
        public override Task <RpcResult <VoidRes> > ExcuteAsync(CommonReq req)
        {
            RpcResult <VoidRes> res = new RpcResult <VoidRes>();

            _logger.LogInformation("serviceId={serviceId},messageId={messageId},data = {data}", req.ServiceId, req.MessageId, req.Data);

            return(Task.FromResult(res));
        }
Exemple #4
0
 //抽象方法
 public abstract Task <RpcResult <VoidRes> > ExcuteAsync(CommonReq req);