Exemplo n.º 1
0
        //同步方法
        public RpcResult <TaskVoidRes> Schedule(ScheduleTaskReq req)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(2001, 102);

            message.FriendlyServiceName = "TaskProducerService.Schedule";


            message.Data = req.ToByteArray();
            var response = base.CallInvoker.BlockingCall(message);

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

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }

            if (response.Data == null)
            {
                result.Data = new TaskVoidRes();
            }
            else
            {
                result.Data = TaskVoidRes.Parser.ParseFrom(response.Data);
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task <RpcResult <TaskVoidRes> > ScheduleSecondTransforAsync(ScheduleTaskReq req, int timeOut = 3000)
        {
            AmpMessage message = AmpMessage.CreateRequestMessage(2001, 106);

            message.FriendlyServiceName = "TaskProducerService.ScheduleSecondTransfor";
            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 <TaskVoidRes>();

            if (response.Code != 0)
            {
                result.Code = response.Code;
            }

            if (response.Data == null)
            {
                result.Data = new TaskVoidRes();
            }
            else
            {
                result.Data = TaskVoidRes.Parser.ParseFrom(response.Data);
            }

            return(result);
        }